Bug 8080

Summary: NodeList (and other DOM lists) items are not enumeratable using for..in
Product: WebKit Reporter: Robin Daugherty <robin>
Component: WebCore JavaScriptAssignee: Sam Weinig <sam>
Severity: Normal CC: ap, ddkilzer, ian, mikel.walters, sam, unik
Priority: P2 Keywords: HasReduction
Version: 420+   
Hardware: Macintosh   
OS: OS X 10.4   
Description Flags
Sample page demonstrating both broken and working methods of stepping through nodeList.
patch andersca: review+

Description Robin Daugherty 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.)
Comment 1 Robin Daugherty 2006-03-30 08:30:25 PST
Created attachment 7392 [details]
Sample page demonstrating both broken and working methods of stepping through nodeList.
Comment 2 Alexey Proskuryakov 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.
Comment 3 Alex Unigovsky 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.
Comment 4 Mark Rowe (bdash) 2008-02-01 08:29:36 PST
*** Bug 17137 has been marked as a duplicate of this bug. ***
Comment 5 Mark Rowe (bdash) 2008-02-01 08:30:25 PST
NodeList, HTMLCollection and StyleSheetList are also affected by this.  See bug 17137 for more info.
Comment 6 Sam Weinig 2008-02-05 20:03:05 PST
Created attachment 18948 [details]
Comment 7 Anders Carlsson 2008-02-05 20:08:09 PST
Comment on attachment 18948 [details]

Comment 8 Sam Weinig 2008-02-05 20:39:08 PST
Landed in r30034.