WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
104096
HTMLCollections namedItem() methods should return null than undefined for empty collections.
https://bugs.webkit.org/show_bug.cgi?id=104096
Summary
HTMLCollections namedItem() methods should return null than undefined for emp...
Aleksei Yu. Semenov
Reported
2012-12-05 00:50:07 PST
HTML5 specification (
http://www.w3.org/TR/html5/the-form-element.html#the-form-element
) define for element 'form' property 'elements' of type HTMLFormControlsCollection. The HTMLFormControlsCollection is defined as follows (
http://www.w3.org/TR/html5/common-dom-interfaces.html#htmlformcontrolscollection-0
): interface HTMLFormControlsCollection : HTMLCollection { // inherits length and item() legacycaller getter object? namedItem(DOMString name); // overrides inherited namedItem() }; "The namedItem(name) method must act according to the following algorithm: 1. If, at the time the method is called, there is exactly one node in the collection that has either an id attribute or a name attribute equal to name, then return that node and stop the algorithm. 2. Otherwise, if there are no nodes in the collection that have either an id attribute or a name attribute equal to name, then return null and stop the algorithm. 3. Otherwise, create a new RadioNodeList object representing a live view of the HTMLFormControlsCollection object, further filtered so that the only nodes in the RadioNodeList object are those that have either an id attribute or a name attribute equal to name. The nodes in the RadioNodeList object must be sorted in tree order. 4. Return that RadioNodeList object." However, namedItem() returns undefined result instead of null for the case #2. Here is sample code: <html> <head> <script type="text/javascript"> function test() { var form = document.createElement('form'); document.body.appendChild(form); document.write('form.elements.namedItem("non-existing-id"): ' + form.elements.namedItem('non-existing-id') + ' (expected: null)'); } </script> </head> <body onload="test()"> </body> </html> The problem is found in Google Chrome 23.0.1271.91 (Official build 167501) m
Attachments
proposed_patch
(8.51 KB, patch)
2013-02-13 14:39 PST
,
Vineet Chaudhary (vineetc)
no flags
Details
Formatted Diff
Diff
View All
Add attachment
proposed patch, testcase, etc.
Vineet Chaudhary (vineetc)
Comment 1
2013-02-13 14:39:17 PST
Created
attachment 188187
[details]
proposed_patch
Hajime Morrita
Comment 2
2013-02-13 15:59:48 PST
Comment on
attachment 188187
[details]
proposed_patch The change looks good. Could you make the test a bit more comprehensive? It's worth covering some neighboring cases in same test.
Kentaro Hara
Comment 3
2013-02-13 16:09:15 PST
Comment on
attachment 188187
[details]
proposed_patch The change looks good. What is the behavior of other browsers?
Vineet Chaudhary (vineetc)
Comment 4
2013-02-13 16:35:12 PST
(In reply to
comment #2
)
> (From update of
attachment 188187
[details]
) > The change looks good. > Could you make the test a bit more comprehensive? > It's worth covering some neighboring cases in same test.
Actually most of the namedItem() tests are already covered in like : fast/dom/collection-item.html collection-nameditem-move-between-documents.html
> The change looks good. What is the behavior of other browsers?
All other browsers behaves as expected ie. returns null.
Kentaro Hara
Comment 5
2013-02-13 16:42:26 PST
Comment on
attachment 188187
[details]
proposed_patch Thanks!
Vineet Chaudhary (vineetc)
Comment 6
2013-02-13 17:06:33 PST
Comment on
attachment 188187
[details]
proposed_patch Thank you!!
WebKit Review Bot
Comment 7
2013-02-13 17:32:55 PST
Comment on
attachment 188187
[details]
proposed_patch Clearing flags on attachment: 188187 Committed
r142831
: <
http://trac.webkit.org/changeset/142831
>
WebKit Review Bot
Comment 8
2013-02-13 17:32:59 PST
All reviewed patches have been landed. Closing bug.
Vineet Chaudhary (vineetc)
Comment 9
2013-02-13 19:53:27 PST
(In reply to
comment #7
)
> (From update of
attachment 188187
[details]
) > Clearing flags on attachment: 188187 > > Committed
r142831
: <
http://trac.webkit.org/changeset/142831
>
Sorry this seems caused regression
bug 109780
.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug