W3C home > Mailing lists > Public > public-script-coord@w3.org > January to March 2012

Re: variable declarations shadowing named properties on window

From: Boris Zbarsky <bzbarsky@MIT.EDU>
Date: Wed, 04 Jan 2012 01:49:32 -0500
Message-ID: <4F03F67C.50700@mit.edu>
To: Ojan Vafai <ojan@chromium.org>
CC: Cameron McCormack <cam@mcc.id.au>, "public-script-coord@w3.org" <public-script-coord@w3.org>, Travis Leithead <Travis.Leithead@microsoft.com>, Allen Wirfs-Brock <allen@wirfs-brock.com>, Ian Hickson <ian@hixie.ch>
On 1/3/12 9:18 PM, Ojan Vafai wrote:
> Firefox behaves differently for frames and elements I believe (or maybe
> names versus IDs?).

Frame names vs global scope polluter.

In Gecko, the global scope polluter is currently implemented as an 
object on the prototype chain of the window, so var declarations will 
always shadow it.  But frames are own properties of the window, and the 
behavior is what it is for exactly the reason Cameron described, as far 
as I can tell.

> My strong preference is that declaring a variable should cause it to
> shadow (i.e. alert undefined above).

Can we move frames away from being own properties of the window (i.e. 
move them onto some prototype)?  That seems like the "simplest" (in 
terms of how it works, not in terms of expressing it in WebIDL) way of 
making var shadow their names.

> Not shadowing has been a frequent
> source of bugs for the Closure Compiler in WebKit. Shadowing makes it
> much easier to reason about how library code will behave when embedded
> in a page.

This argues for not having any sort of weird own property behavior on 
Window at all and putting all that on some prototype of the window.

That will incidentally simplify implementation in Gecko, I believe 
(because it doesn't require having a proxy or otherwise "weird" object 
as a global object).

Received on Wednesday, 4 January 2012 07:08:24 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 17:14:05 UTC