Bug 17184
Summary: | Node.childNodes returns a new NodeList each time | ||
---|---|---|---|
Product: | WebKit | Reporter: | boucher <rboucher> |
Component: | DOM | Assignee: | Nobody <webkit-unassigned> |
Status: | RESOLVED DUPLICATE | ||
Severity: | Normal | CC: | abarth, ap, kling, pf, sam |
Priority: | P2 | ||
Version: | 523.x (Safari 3) | ||
Hardware: | Mac | ||
OS: | OS X 10.5 |
boucher
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.
Attachments | ||
---|---|---|
Add attachment proposed patch, testcase, etc. |
boucher
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.
Alexey Proskuryakov
See also: bug 9508, bug 33696.
Pablo Flouret
Looks like this one got fixed by bug 76591.
Adam Barth
*** This bug has been marked as a duplicate of bug 76591 ***