Re: "var" declarations shadowing properties from Window.prototype

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 
http://dev.w3.org/2006/webapi/WebIDL/#NamedPropertiesObject (which 
Window uses).  There was a bunch of previous discussion about this at 
http://lists.w3.org/Archives/Public/public-script-coord/2012JanMar/0010.html 
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...

-Boris

Received on Sunday, 12 August 2012 20:55:49 UTC