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

Martin Honnen <[email protected]> Thu, 15 Nov 2012 15:29:20 +0100
Newsgroups gmane.comp.mozilla.devel.dom
Organization Liberty Development
Message-ID <[email protected]>
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