RESOLVED FIXED 8080
NodeList (and other DOM lists) items are not enumeratable using for..in
https://bugs.webkit.org/show_bug.cgi?id=8080
Summary NodeList (and other DOM lists) items are not enumeratable using for..in
Robin Daugherty
Reported 2006-03-30 08:28:17 PST
I get a nodeList from getElementsByName, getElementsByTagName, etc. I then want to step through the list. In IE and Firefox, I can use a for...in statement to step through the nodeList as an array. However, in Safari and latest Nightly of WebKit, the for...in statement does nothing. Silently. (Not sure whether this should be in Javascript or HTML DOM.)
Attachments
Sample page demonstrating both broken and working methods of stepping through nodeList. (874 bytes, text/html)
2006-03-30 08:30 PST, Robin Daugherty
no flags
patch (21.35 KB, patch)
2008-02-05 20:03 PST, Sam Weinig
andersca: review+
Robin Daugherty
Comment 1 2006-03-30 08:30:25 PST
Created attachment 7392 [details] Sample page demonstrating both broken and working methods of stepping through nodeList.
Alexey Proskuryakov
Comment 2 2007-01-07 08:45:28 PST
Please note the values that get enumerated by for...in in Firefox: {0, 1, 2, 3, 4, length, item, namedItem}. In TOT WebKit, we get just {length, item}. So, while WebKit may have a problem with property enumeration, this doesn't look like a valid way to iterate a NodeList.
Alex Unigovsky
Comment 3 2007-03-02 19:19:28 PST
The thing I can confirm is that typeof(SomeObject.getElementsByTagName('sometag')) is 'function' instead of an 'object'. Confirmed on Safari 2.0.4 and nightly 19940.
Mark Rowe (bdash)
Comment 4 2008-02-01 08:29:36 PST
*** Bug 17137 has been marked as a duplicate of this bug. ***
Mark Rowe (bdash)
Comment 5 2008-02-01 08:30:25 PST
NodeList, HTMLCollection and StyleSheetList are also affected by this. See bug 17137 for more info.
Sam Weinig
Comment 6 2008-02-05 20:03:05 PST
Anders Carlsson
Comment 7 2008-02-05 20:08:09 PST
Comment on attachment 18948 [details] patch r=me
Sam Weinig
Comment 8 2008-02-05 20:39:08 PST
Landed in r30034.
Note You need to log in before you can comment on or make changes to this bug.