Re: variable declarations shadowing named properties on window

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).

-Boris

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