Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

should window.foo return a HTMLCollection if div id=foo and form name=foo exist?

25 views
Skip to first unread message

Martin Honnen

unread,
Nov 15, 2012, 9:29:20 AM11/15/12
to
Hi,

the test case
http://home.arcor.de/martin.honnen/javascript/2012/test2012111502.html
has <div id="foo">...</div> and <form name="foo">...</form>.

In that case according to
http://www.w3.org/TR/html5/browsers.html#named-access-on-the-window-object
I think that
window.foo
should a return a HTMLCollection containing both the div and the form
element.

However with Firefox (tested both with release 16.0.2 and nightly 18.0a2
(2012-11-14) on Windows 7) I have two problems, first the access to
window.foo
yields undefined, then an access to the unqualified
foo
yields a single HTMLDivElement, then suddenly the access to
window.foo
is no longer undefined but gives the HTMLDivElement as well.

So two questions, why is "window.foo" first undefined and suddenly
defined after an access to "foo"?

And shouldn't "window.foo" as well as "foo" not return a HTMLCollection?
Chrome (tested with 23.0.1271.64) and Opera (tested with 12.10) do that.

Regards

Martin

Boris Zbarsky

unread,
Nov 15, 2012, 9:43:51 AM11/15/12
to
On 11/15/12 6:29 AM, Martin Honnen wrote:
> So two questions, why is "window.foo" first undefined and suddenly
> defined after an access to "foo"?

Because we used to only do global scope pollution on unqualified
lookups. I suggest retesting in a nightly build.

> And shouldn't "window.foo" as well as "foo" not return a HTMLCollection?

At the moment, our gsp implementation does the bare minimum needed for
web compat (given that we only recently gave up on trying to get this
removed from the spec in the first place). If someone wants to make it
more complicated to match the spec here, I'm happy to review the patch,
but otherwise it's a low priority, since this entire "feature" is
completely broken by design and bad for the web to start with....

-Boris

Martin Honnen

unread,
Nov 15, 2012, 9:48:27 AM11/15/12
to
Boris Zbarsky wrote:
> On 11/15/12 6:29 AM, Martin Honnen wrote:
>> So two questions, why is "window.foo" first undefined and suddenly
>> defined after an access to "foo"?
>
> Because we used to only do global scope pollution on unqualified
> lookups. I suggest retesting in a nightly build.

Is Aurora 18.0a2 (2012-11-14) not a nightly? With that I see the output


window.foo

window.foo: undefined
foo

foo: [object HTMLDivElement]
window.foo

window.foo: [object HTMLDivElement]




0 new messages