Bug 74546
Summary: | HTMLCollection.item should not return elements by ID/name | ||
---|---|---|---|
Product: | WebKit | Reporter: | Ms2ger (he/him; ⌚ UTC+1/+2) <Ms2ger> |
Component: | DOM | Assignee: | Nobody <webkit-unassigned> |
Status: | RESOLVED DUPLICATE | ||
Severity: | Normal | CC: | arv, bzbarsky, rniwa, sam |
Priority: | P2 | ||
Version: | 528+ (Nightly build) | ||
Hardware: | Unspecified | ||
OS: | Unspecified |
Ms2ger (he/him; ⌚ UTC+1/+2)
Currently, the implementation of item(unsigned long) looks at the ID/name of elements in the collection if the argument isn't an integer, for some value of integer. [1,2] WebIDL, [3] however, requires that the argument is converted into an integer by ToNumber, which returns NaN for normal strings, and then ToUint32, which is 0. So item("foo") should return the first element in the collection.
[1] <http://www.google.com/codesearch#OAMlx_jo-ck/src/third_party/WebKit/Source/WebCore/bindings/js/JSHTMLCollectionCustom.cpp&exact_package=chromium&q=HTMLCollection&l=74>
[2] <http://software.hixie.ch/utilities/js/live-dom-viewer/saved/1280>
[3] <http://dev.w3.org/2006/webapi/WebIDL/#es-unsigned-long>
Attachments | ||
---|---|---|
Add attachment proposed patch, testcase, etc. |
Erik Arvidsson
FWIW: IE9 does not do the ID lookup and item("foo") is treated as item(0)
Ryosuke Niwa
(In reply to comment #1)
> FWIW: IE9 does not do the ID lookup and item("foo") is treated as item(0)
Right because item takes an index, not an id. The problem is that we're currently returning a list of nodes :(
Boris Zbarsky
Dup of bug 74468?
Ryosuke Niwa
(In reply to comment #3)
> Dup of bug 74468?
So it seems.
*** This bug has been marked as a duplicate of bug 74468 ***