Open Bug 1010241 Opened 11 years ago Updated 2 years ago

Named access on the Window object (via gsp, or global scope polluter) doesn't return an HTMLCollection when multiple elements have the relevant name

Categories

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

32 Branch
x86_64
Windows 7
defect

Tracking

()

People

(Reporter: crimsteam, Unassigned)

References

(Depends on 1 open bug, Blocks 1 open bug)

Details

User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:29.0) Gecko/20100101 Firefox/29.0 (Beta/Release) Build ID: 20140506152807 Steps to reproduce: In HTML spec we have this: http://www.whatwg.org/specs/web-apps/current-work/#named-access-on-the-window-object But in Firefox for more than one element with same name or id we don't get HTMLCollection, but single element. Chrome and IE works as HTML said. Small test: <img name="ups" src=""> <img id="ups" src=""> <p id="correct">First P.</p> <script> document.write(correct); // [object HTMLParagraphElement] document.write("<br>"); document.write(this.correct); // [object HTMLParagraphElement] document.write("<br>"); document.write(window.correct); // [object HTMLParagraphElement] document.write("<br><br>"); document.write(ups); // [object HTMLImageElement] (should be [object HTMLCollection]) document.write("<br>"); document.write(this.ups); // [object HTMLImageElement] (should be [object HTMLCollection]) document.write("<br>"); document.write(window.ups); // [object HTMLImageElement] (should be [object HTMLCollection]) </script> I don't check every case (nested browsing context).
Note also bug 903572. It's not clear whether the current spec draft (which just documented what IE did, last I checked) is really what we want here.
Depends on: 903572
Summary: Named access on the Window object is wrong → Named access on the Window object (via gsp, or global scope polluter) doesn't return an HTMLCollection when multiple elements have the relevant name
Very well that you wrote, because I planned to open next for the Document, now I see its not necessary. And in fact it looks like documented exactly what IE did: <img id="ups" name="" src=""> <br> <script> document.write(document.ups); // undefined in IE, [object HTMLImageElement] in Chrome and Firefox </script> but in other site Firefox still has more differences: <img name="ups" src=""> <img name="ups" src=""> <br> <script> document.write(document.ups); // [object NodeList] in Firefox, [object HTMLCollection] in Chrome and IE </script> Just report this and wait what you decide in the future.
Status: UNCONFIRMED → NEW
Ever confirmed: true
Priority: -- → P3
Blocks: html
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.