W3C home > Mailing lists > Public > whatwg@whatwg.org > April 2011

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

From: Boris Zbarsky <bzbarsky@MIT.EDU>
Date: Fri, 01 Apr 2011 08:50:40 -0400
Message-ID: <4D95CA20.6030104@mit.edu>
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 
quirks-only.

-Boris
Received on Friday, 1 April 2011 05:50:40 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 30 January 2013 18:48:03 GMT