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 

Received on Friday, 1 April 2011 05:50:40 UTC

This archive was generated by hypermail 2.3.1 : Monday, 13 April 2015 23:09:05 UTC