Bug 8080 - NodeList (and other DOM lists) items are not enumeratable using for..in
Summary: NodeList (and other DOM lists) items are not enumeratable using for..in
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore JavaScript (show other bugs)
Version: 420+
Hardware: Mac OS X 10.4
: P2 Normal
Assignee: Sam Weinig
URL:
Keywords: HasReduction
: 17137 (view as bug list)
Depends on:
Blocks:
 
Reported: 2006-03-30 08:28 PST by Robin Daugherty
Modified: 2008-02-05 20:39 PST (History)
6 users (show)

See Also:


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 Details
patch (21.35 KB, patch)
2008-02-05 20:03 PST, Sam Weinig
andersca: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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]
patch
Comment 7 Anders Carlsson 2008-02-05 20:08:09 PST
Comment on attachment 18948 [details]
patch

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