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
Created attachment 188187 [details] proposed_patch
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.
Comment on attachment 188187 [details] proposed_patch The change looks good. What is the behavior of other browsers?
(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.
Comment on attachment 188187 [details] proposed_patch Thanks!
Comment on attachment 188187 [details] proposed_patch Thank you!!
Comment on attachment 188187 [details] proposed_patch Clearing flags on attachment: 188187 Committed r142831: <http://trac.webkit.org/changeset/142831>
All reviewed patches have been landed. Closing bug.
(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.