Closed Bug 1397682 Opened 7 years ago Closed 7 years ago

Window named getter does not return all elements with a given ID

Categories

(Core :: DOM: Core & HTML, defect)

defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 1010241

People

(Reporter: annevk, Unassigned)

Details

Import this test from web-platform-tests: html/browsers/the-window-object/named-access-on-the-window-object/named-objects.html The subtest named "Check if window['b'] returns the elements with the id='b'" cannot find <input id=b> for some reason. (Note that this test was recently modified in https://github.com/w3c/web-platform-tests/pull/7267 to fix a regression after <applet> removal caused a minor problem. That shouldn't affect this subtest though.)
Is this a recent failure or has it been happening for a while (do we know)?
Flags: needinfo?(annevk)
I don't know, bz probably does.
Flags: needinfo?(annevk) → needinfo?(bzbarsky)
The test asserts that window['b'] is a list of the two elements with id="b". That's because of step 4 of <https://html.spec.whatwg.org/#dom-window-nameditem>. Note that this is basically speccing the global scope polluter. We've never implemented this part of the spec in its current form; we implemented the bare minimum global scope pollution needed for web compat. Specifically, what we implement is: 1) Look for named child windows with the given name. If one is found, return it. 2) Look for the first element whose id is the given string. If found, return it. 3) Return whatever the named getter on HTMLDocument returns for the given string. As I noted in bug 1010241, of which this is a duplicate, it's not clear to me that all this complexity in the GSP is really desirable. Unfortunately, I had no luck getting hixie to drop any of the complexity... I should note that the spec is still ambiguous in step 4 as to whether it's the same HTMLCollection each time or not... Anyway, the short answer is that our behavior here dates back to when we first implemented the GSP; it's not a recent change of any sort.
Flags: needinfo?(bzbarsky)
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → DUPLICATE
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.