royale-asjs icon indicating copy to clipboard operation
royale-asjs copied to clipboard

Array - sortOn fails for XML data

Open yishayw opened this issue 3 years ago • 1 comments

In this app

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                applicationComplete="init()"
                width="100%"
                height="100%"
                xmlns:s="library://ns.apache.org/royale/spark"
                xmlns:mx="library://ns.apache.org/royale/mx">
                
     <fx:Script>
        <![CDATA[
            import mx.managers.PopUpManager;
            private function init():void
            {
                var arr:Array = [<node label="b"/>, <node label="a"/>];
                arr.sortOn(["@label"]);
                trace(((arr[0] as XML).@label).toString());
            }
        ]]>
    </fx:Script>
</mx:Application>

I would expect the trace output to be 'a' (as it is in Flex), but instead it is 'b'.

Apparently flash player knows how to parse XML and can sort an array of XML objects, but Language.as does assumes the objects are simple and does not read @label correctly.

As, in Royale, XML is a separate library the question is whether Language.as where this sortOn function is location, is, or even should be, made aware of XML objects.

yishayw avatar Jun 13 '22 10:06 yishayw

https://github.com/apache/royale-asjs/pull/1150

estanglerbm avatar Jun 13 '22 22:06 estanglerbm