[Laszlo-dev] [Laszlo-checkins] r11021 - openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf
André Bargull
andre.bargull at udo.edu
Wed Sep 17 07:19:38 PDT 2008
And for swf9, Adobe made things even worse (if you need to rely on any
ordering).
[1]
http://www.stevensacks.net/2008/04/07/as3-forin-object-does-not-behave-like-as2/
[2] http://www.darronschall.com/weblog/archives/000207.cfm
and many others...
On 9/17/2008 3:10 PM, P T Withington wrote:
> FWIW, JS2 was going to spec that iterating over an object had to happen
> in the order the elements were inserted (what all but swf8 already do).
> I don't know if this is a fix that is going to go into 3.1.
>
> On 2008-09-16, at 11:16EDT, bargull at openlaszlo.org wrote:
>
>> Author: bargull
>> Date: 2008-09-16 08:16:38 -0700 (Tue, 16 Sep 2008)
>> New Revision: 11021
>>
>> Modified:
>> openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzLoader.lzs
>> Log:
>> Change 20080916-bargull-UDy by bargull at dell--p4--2-53 on 2008-09-16
>> 14:31:15
>> in /home/Admin/src/svn/openlaszlo/trunk
>> for http://svn.openlaszlo.org/openlaszlo/trunk
>>
>> Summary: xml attribute order
>>
>> New Features:
>>
>> Bugs Fixed: LPP-3379
>>
>> Technical Reviewer: hminsky
>> QA Reviewer: (pending)
>> Doc Reviewer: (pending)
>>
>> Documentation:
>>
>> Release Notes:
>>
>> Details:
>> Both, dhtml and swf9, preserve the xml-attribute order. But for swf8
>> and a compiled-in dataset resp. a http-dataset with nsprefix=false,
>> the xml-attribute order is reversed. This happens because flash
>> iterates over an object in reversed insertion order. But if we insert
>> every xml-attribute also in reversed order, both reversions nullify
>> each other and people will stop complaining about this issue.
>> Additionally, I've copied the "fast-path" attribute copy code from the
>> iterative xml-copy version to the recursive one.
>>
>>
>>
>> Tests:
>> alldata passes
>> testcase at bugreport
>>
>>
>>
>> Modified: openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzLoader.lzs
>> ===================================================================
>> --- openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzLoader.lzs
>> 2008-09-16 15:13:09 UTC (rev 11020)
>> +++ openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzLoader.lzs
>> 2008-09-16 15:16:38 UTC (rev 11021)
>> @@ -444,19 +444,34 @@
>> }
>> lfcnode = new LzDataText(nv);
>> } else {
>> - // slow but sure way to copy attributes
>> - var nattrs = node.attributes;
>> - var cattrs = {};
>> - for (var key in nattrs) {
>> - var nkey = key;
>> - if (!nsprefix) {
>> + if (! nsprefix) {
>> + // slow but sure way to copy attributes
>> + var nattrs = node.attributes;
>> + var cattrs = {};
>> + var attrlist = [];
>> + for (var key in nattrs) {
>> + var nkey = key;
>> // strip namespace prefixes
>> var colpos = key.indexOf(':');
>> if (colpos >= 0) {
>> - nkey = key.substring(colpos+1);
>> + nkey = key.substring(colpos + 1);
>> }
>> + //cattrs[nkey] = nattrs[key];
>> + attrlist.push(nkey, nattrs[key]);
>> }
>> - cattrs[nkey] = nattrs[key];
>> +
>> + // Flash iterates over an object in reversed insertion
>> order.
>> + // But as we want to preserve the original xml-attribute
>> order,
>> + // we need to insert the attributes also in reversed order.
>> + for (var i = attrlist.length - 1; i >= 0; i -= 2) {
>> + cattrs[attrlist[i - 1]] = attrlist[i];
>> + }
>> + } else {
>> + // this is the fast path
>> + var cattrs = node.attributes;
>> + cattrs.__proto__ = Object.prototype;
>> + cattrs.constructor = Object;
>> + ASSetPropFlags(cattrs, ['__proto__', 'constructor'], 1, 7);
>> }
>>
>> var nname = node.nodeName;
>> @@ -597,23 +612,31 @@
>> // After this works, try bashing the __proto__
>> // and see if GC still works.
>>
>> - var stripnsprefix = !nsprefix;
>> - var nattrs = node.attributes;
>> - var cattrs;
>> - if (stripnsprefix) {
>> + if (! nsprefix) {
>> // this is slow, we iterate over every attribute name
>> - cattrs = {};
>> + var nattrs = node.attributes;
>> + var cattrs = {};
>> + var attrlist = [];
>> for (var key in nattrs) {
>> var nkey = key;
>> + // strip namespace prefixes
>> var colpos = key.indexOf(':');
>> if (colpos >= 0) {
>> - nkey = key.substring(colpos+1);
>> + nkey = key.substring(colpos + 1);
>> }
>> - cattrs[nkey] = nattrs[key];
>> + //cattrs[nkey] = nattrs[key];
>> + attrlist.push(nkey, nattrs[key]);
>> }
>> +
>> + // Flash iterates over an object in reversed
>> insertion order.
>> + // But as we want to preserve the original
>> xml-attribute order,
>> + // we need to insert the attributes also in reversed
>> order.
>> + for (var i = attrlist.length - 1; i >= 0; i -= 2) {
>> + cattrs[attrlist[i - 1]] = attrlist[i];
>> + }
>> } else {
>> // this is the fast path
>> - cattrs = node.attributes;
>> + var cattrs = node.attributes;
>> cattrs.__proto__ = oproto;
>> cattrs.constructor = Object;
>> ASSetPropFlags(cattrs, ['__proto__', 'constructor'],
>> 1, 7);
>> @@ -638,7 +661,6 @@
>> attributes: cattrs,
>> ownerDocument: lfcparent.ownerDocument,
>> parentNode: lfcparent};
>> -
>> }
>>
>> // Add to the parent's childnodes.
>>
>>
>> _______________________________________________
>> Laszlo-checkins mailing list
>> Laszlo-checkins at openlaszlo.org
>> http://www.openlaszlo.org/mailman/listinfo/laszlo-checkins
>
>
More information about the Laszlo-dev
mailing list