For literals, yes, we’d for the most part just pass the whole thing as a string to the constructor. The only exception I can think of is bracket notation:
var foo:XML = <node><subnode attr={myAttr}>foo</subnode></node>; would have to become: var foo:XML = new XML('<node><subnode attr="‘+myAttr+’">foo</subnode></node>’); Wrapping the xml in a dummy node is a good idea. I like that. Thanks! On Jan 4, 2016, at 6:08 PM, Alex Harui <aha...@adobe.com> wrote: > Looks like there currently isn't any XML Literal handling for AS -> JS. > > For AS code like: > > var foo:XML = <node><subnode attr="1">foo</subnode></node>; > > What do you want the output to be? Shouldn't we just pass the whole thing > to the XML() function? > > var foo = new XML('<node><subnode attr="1">foo</subnode></node>'); > > Or do you want something else? > > For XMLList literals, can you just wrap it in a dummy node and let JS > parse it? > > var bar:XMLList = new XMLList("<node attr='1' /><node attr='2' />"); > > Is that the same as: > > var bar:XMLList = new XML("<dummy><node attr='1' /><node attr='2' > /></dummy>").children(); > > -Alex > > On 1/4/16, 8:00 AM, "Harbs" <harbs.li...@gmail.com> wrote: > >> Here’s an implementation question: >> >> Apparently, it’s possible to pass a string into an XMLList constructor to >> create an XMLList of multiple XML objects. I’m not sure of the best way >> to handle this. >> >> I can walk the contents of the string and split the string into multiple >> XML strings and create separate XML objects from that, but I’m concerned >> that it might be error-prone. Does anyone know of a cheap method of >> parsing a string into multiple nodes in standard javascript? >> >> On Jan 4, 2016, at 5:06 PM, Harbs <harbs.li...@gmail.com> wrote: >> >>> Another issue: >>> >>> XML literals and angle brackets. >>> >>> Is the compiler handling xml literals at all now? I think angle bracket >>> notation need to be converted to string concatenation as well. >>> >>> On Dec 31, 2015, at 5:21 PM, Alex Harui <aha...@adobe.com> wrote: >>> >>>> Sounds reasonable. Do you want to try to make the changes to the >>>> compiler >>>> yourself? >>>> >>>> I think you can just copy the pattern in this commit: >>>> 22fa6defa3ed2896de4eba1a5a1b316e1e3c2b0f >>>> In these files: BinaryOperatorEmitter.java and >>>> TestFlexJSGlobalClasses.java >>>> >>>> -Alex >>>> >>>> On 12/31/15, 1:02 AM, "Harbs" <harbs.li...@gmail.com> wrote: >>>> >>>>> Another question: >>>>> >>>>> How should we handle equality? According to the E4X spec, if regular >>>>> equality is used, it returns true if the structure of the XML matches >>>>> even if the objects are different objects. So: >>>>> >>>>> var xml1 = <foo><baz /></foo>; >>>>> var xml2 = <foo><baz/></foo>; >>>>> xml1 == xml2 // true >>>>> xml1 === xml2 // false >>>>> xml1 === xml1 // true >>>>> var xml1 = <foo><baz /></foo>; >>>>> var xml2 = <foo><baz name="baz"/></foo>; >>>>> xml1 == xml2 // false >>>>> xml1 === xml2 // false >>>>> xml1 === xml1 // true >>>>> >>>>> I’m thinking I should add an equals(xml) method which you’d map to the >>>>> “==" operator. >>>> >>> >> >