This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.
Should NodeList, DOMTokenLists, and other list enumerables behave like Array enumerables? Right now, properties like "length", "item", "add", "remove", "toggle", and "contains" are enumerable, which makes for (e in someList) not as zesty as for (e in someArray).
It is considered bad practice to use for-in loops for arrays and array like objects. FWIW, "length" is non enumerable in IE and Firefox. It is enumerable in WebKit/JSC, WebKit/V8 and Opera. ES6 solves this using the for-of loop wich uses an iteration hook. http://wiki.ecmascript.org/doku.php?id=harmony:specification_drafts. The right thing to do is probably to spec that the default iterator of these things should be that same as Array.prototype.iterator. which would allow us to do:" for (var element of document.querySelectorAll('p')) { assert(element.tagName === 'P'); }
Jonathan, "for (e in someArray)" is pretty broken, since it will enumerate all sorts of things in various cases. Just don't go there. ;) Gecko+Spidermonkey already has support for for-of on lists. And there's discussion about making that automatic in WebIDL.
Jonathan, our plan of dealing with this is bug 17648. Hopefully that is okay with you. Please let me know if you have any concerns.