"var" declarations shadowing properties from Window.prototype
bzbarsky at MIT.EDU
Sun Aug 12 13:55:13 PDT 2012
On 8/12/12 4:31 PM, Brendan Eich wrote:
> However, check me here: the GSP makes "own" global properties on demand,
> when names of DOM elements that come from name= and id= attributes (or
> just id=? I forget) are used as identifier expressions.
That's what it does in Gecko's impl right now. It has a bunch of
issues, including the properties not going away when the name or id
attributes change or the relevant element is removed from the document.
If you want properties to go away, then you need to either explicitly
delete the properties (and then you have to be able to tell apart
properties you added from properties the page defined!) or you have to
use a proxy (in ES5 terms).
Per the current spec proposal, the GSP lives on the proto chain and
exposes the various id/name stuff as own properties on itself, with the
usual caveats about checking up the proto chain first that DOM named
access has. See
Window uses). There was a bunch of previous discussion about this at
and following, though it's not clear to me now whether the solution we
decided on allows var to shadow these named props as desired after all...
More information about the es-discuss