Bug 17184 - Node.childNodes returns a new NodeList each time
Summary: Node.childNodes returns a new NodeList each time
Status: RESOLVED DUPLICATE of bug 76591
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: 523.x (Safari 3)
Hardware: Mac OS X 10.5
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-02-05 12:52 PST by boucher
Modified: 2012-02-17 15:16 PST (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description boucher 2008-02-05 12:52:47 PST
The NodeList object, which is returned by element.childNodes, among other things, cannot have properties assigned to it.  It also doesn't have any of the built in array functions.  

Firefox (and I believe Internet Explorer, but cannot test right this moment) supports adding aribtrary properties to the objects returned by element.childNodes, as well as the built in array functions on those objects.  

This is related to the following two bugs:
http://bugs.webkit.org/show_bug.cgi?id=8080
http://bugs.webkit.org/show_bug.cgi?id=7967

These bugs note that it doesn't respond to for..in, and that similarly Collections returned from a form element can't have properties set.
Comment 1 boucher 2008-02-05 13:00:12 PST
Apparently the actual problem here is that every time you call element.childNodes, you get a new NodeList. 

So, the following will not work:

element.childNodes.foo = 1;
alert(element.childNodes.foo); //undefined

But, this does work:

var e = element.childNodes;
e.foo = 1;
alert(e.foo);

Obviously the severity of this is significantly less now, since the alternate method is acceptable.  Though it would be ideal if two immediate requests to element.childNodes returned the same list.
Comment 2 Alexey Proskuryakov 2010-11-30 12:23:43 PST
See also: bug 9508, bug 33696.
Comment 3 Pablo Flouret 2012-02-17 15:15:07 PST
Looks like this one got fixed by bug 76591.
Comment 4 Adam Barth 2012-02-17 15:16:41 PST

*** This bug has been marked as a duplicate of bug 76591 ***