Closed Bug 724033 Opened 13 years ago Closed 13 years ago

Iterating over a NodeList doesn't show length and item properties

Categories

(Core :: DOM: Core & HTML, defect)

10 Branch
x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 691707

People

(Reporter: simon, Unassigned)

References

Details

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:9.0.1) Gecko/20100101 Firefox/9.0.1 Build ID: 20111220165912 Steps to reproduce: Consider the following code: for(var a in document.getElementsByTagName("a")) console.log(a); Actual results: In Firefox 9, this logs the indices of the list, as well as length, item, and namedItem. In the latest versions of Safari 5.1.2 and Chrome 18.0.125.3.dev, this logs the indices of the list as well as length and item. In Firefox 10, this logs only the indices of the list. Expected results: I don't really know whether this is a bug or not. I _think_ the DOM4 draft suggests that one should iterate over the length and item properties, but the new behavior makes more sense (even though it broke our code). In any case, this kind of change should be documented.
Version: 9 Branch → 10 Branch
Blocks: 648801
Component: Untriaged → DOM
Product: Firefox → Core
QA Contact: untriaged → general
This is a bug. The new nodelist bindings need to enumerate up the proto chain.
Status: UNCONFIRMED → NEW
Ever confirmed: true
And in fact, the code says: ListBase<LC>::enumerate(JSContext *cx, JSObject *proxy, AutoIdVector &props) { // FIXME: enumerate proto as well return getOwnPropertyNames(cx, proxy, props); } Gah. Would have been nice to find out about this before release. :( Peter, do you want to take this?
Status: NEW → RESOLVED
Closed: 13 years ago
Resolution: --- → DUPLICATE
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.