RESOLVED DUPLICATE of bug 74468 74546
HTMLCollection.item should not return elements by ID/name
https://bugs.webkit.org/show_bug.cgi?id=74546
Summary HTMLCollection.item should not return elements by ID/name
Ms2ger (he/him; ⌚ UTC+1/+2)
Reported 2011-12-14 15:09:28 PST
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
Erik Arvidsson
Comment 1 2011-12-14 15:15:25 PST
FWIW: IE9 does not do the ID lookup and item("foo") is treated as item(0)
Ryosuke Niwa
Comment 2 2011-12-14 15:20:37 PST
(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
Comment 3 2011-12-14 15:59:06 PST
Dup of bug 74468?
Ryosuke Niwa
Comment 4 2011-12-14 16:00:57 PST
(In reply to comment #3) > Dup of bug 74468? So it seems. *** This bug has been marked as a duplicate of bug 74468 ***
Note You need to log in before you can comment on or make changes to this bug.