Bug 148880

Summary: HTMLOptionsCollection.namedItem should return a NodeList when there are multiple matching nodes
Product: WebKit Reporter: Ryosuke Niwa <rniwa>
Component: FormsAssignee: Keith Rollin <krollin>
Status: RESOLVED FIXED    
Severity: Normal CC: cdumez, krollin, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   

Description Ryosuke Niwa 2015-09-04 20:33:46 PDT
See https://html.spec.whatwg.org/multipage/infrastructure.html#htmloptionscollection

Unlike named getters, we must return a NodeList that contain the list of all matching nodes in HTMLOptionCollection.namedItem.
Comment 1 Ryosuke Niwa 2015-09-04 20:34:23 PDT
This bug was found by the newly added test:
LayoutTests/http/tests/w3c/html/semantics/forms/the-select-element/common-HTMLOptionsCollection-namedItem.html
Comment 2 Radar WebKit Bug Importer 2015-09-04 20:34:25 PDT
<rdar://problem/22590497>
Comment 3 Chris Dumez 2015-10-14 09:52:12 PDT
Where is this in the spec?

The IDL says namedItem() returns an Element. And there is this comment:
"""
element = collection . namedItem(name)
element = collection[name]
Returns the item with ID or name name from the collection.

If there are multiple matching items, then the first is returned.
"""

Therefore, the spec seems to indicate we should NOT return a NodeList. Maybe it is a bug in the test?
Comment 4 Keith Rollin 2015-10-14 10:45:39 PDT
I've filed a w3c-test bug: https://github.com/w3c/web-platform-tests/issues/2255
Comment 5 Keith Rollin 2015-11-03 12:48:23 PST
I've submitted a patch to the test and create a pull-request: https://github.com/w3c/web-platform-tests/pull/2302
Comment 6 Keith Rollin 2016-10-12 12:55:36 PDT
Merged and closed (back in February).