[whatwg] [WHATWG] HTMLElement ids as global object properties

Boris Zbarsky bzbarsky at MIT.EDU
Fri Apr 1 05:50:40 PDT 2011

On 4/1/11 3:26 AM, Alexandre Morgaut wrote:
> It is neither part of HTML5

Sadly, it is.  Kyle linked to the relevant spec bit.

> Let's imagine the effects of existing HTMLElements with id like "location", "document", "event", "toolbar", or even "window"...

The id lookup happens after all other property resolution in browsers 
(but NOT in the current spec text, note), so if you had <div 
id="location"> and accessed window.location you would get a Location 
object, not the <div>.

> One of the main best practices in JavaScript development is "Don't pollute the global namespace"

Clearly agreed, given the bug report I filed about making this quirks-only.

All you have to do is convince the Trident, Webkit, and Presto teams... 
on the other hand I would love to hear from the latter two what their 
thoughts are.  So far the only feedback I've gotten Microsoft saying 
they will likely run into web compat issues if they make the behavior 


More information about the whatwg mailing list