[whatwg] Adding ECMAScript 5 array extras to HTMLCollection (JZ and David Bruant)

Frank Migacz fmigacz at gmail.com
Mon Apr 26 11:25:31 PDT 2010


   What is the implication of denying dynamic changes to the HTMLCollection
in a CORS environment?  In some variant of Comet (or asynchronous UA
polling), how can the UA implement change if it is regularly processing
inside locked control blocks?

   Please pardon my ignorance of the details.

Frank Migacz, Technical Instructor
fmigacz at gmail.com

excerpt:
>> As far as I can see, liveness of HTMLCollection actually does matter.
When
>> iterating over HTMLCollection, it's more or less a rule of thumb to
"save"
>> length, to avoid any kind of mismatch (in case code within loop modifies
>> document and so affects length of collection in question):
>>
>> for (var i = 0, length = collection.length; i < length; i++)
>> // instead of:
>> for (var i = 0; i < collection.length; i++)
>>

And another excerpt:
>> For push, I think that :
>>
>> collection.push(document.createTextNode('foo'));
>>
>> // should behave exactly as :
>>
>> collection.childNodes[collection.length] =
document.createTextNode('foo');
>>
>> I don't know what is the current behavior, but if it throws an error,
>> push should throw the same error. If it appends a text node to the body,
>> then push should do the same.
>> sort is a bunch of :
>>
>> "tmp = collection[i];
>> collection[i] = collection[j];
>> collection[j] = tmp"
>>
>> The first instruction is harmless, but if the second one would throw an
>> error, then let's throw the same error for .sort.
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.whatwg.org/pipermail/whatwg-whatwg.org/attachments/20100426/5de11c4f/attachment-0001.htm>


More information about the whatwg mailing list