[whatwg] [WHATWG] HTMLElement ids as global object properties
Alexandre Morgaut
Alexandre.Morgaut at 4d.com
Sun Apr 3 09:53:37 PDT 2011
On 1 avr. 2011, at 14:50, Boris Zbarsky wrote:
>
>> 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>.
So you can not rely on being able to access an HTMLElement from its id this way...
(As any Javascript code could use a global variable with the same name/id)
>
>> 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.
Is there any registered bug on Opera and Webkit about this topic ?
Or have we got to create one ?
> 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
Alexandre Morgaut
Product Manager
4D SAS
60, rue d'Alsace
92110 Clichy
France
Standard : +33 1 40 87 92 00
Email : Alexandre.Morgaut at 4d.com
Web : www.4D.com
More information about the whatwg
mailing list