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

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

From: Boris Zbarsky <bzbarsky@MIT.EDU>
Date: Sun, 12 Aug 2012 16:55:13 -0400
Message-ID: <50281831.50305@mit.edu>
To: Brendan Eich <brendan@mozilla.com>
CC: Brandon Benvie <brandon@brandonbenvie.com>, public-script-coord@w3.org, es-discuss@mozilla.org
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

This archive was generated by hypermail 2.3.1 : Wednesday, 8 May 2013 19:30:06 UTC