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: Thu, 05 Jan 2012 13:44:37 -0500
Message-ID: <4F05EF95.8020008@mit.edu>
To: Travis Leithead <travis.leithead@microsoft.com>
CC: Cameron McCormack <cam@mcc.id.au>, Ojan Vafai <ojan@chromium.org>, "public-script-coord@w3.org" <public-script-coord@w3.org>, Allen Wirfs-Brock <allen@wirfs-brock.com>, Ian Hickson <ian@hixie.ch>
On 1/5/12 1:39 PM, Travis Leithead wrote:
>>> Note that this does not obviate the need for the no-overriding-builtins
>>> stuff, though, because you don't want to shadow Object.prototype on the
>>> named props object either...
>>
>> Yeah.
>>
>>> So it might be possible to move the named props object to the other spot
>>> in the proto chain.
>
>
> I'm getting a little confused with the proposed changes here. GSP is not part of the prototype chain

Right now, that's correct.

If that's the case, then working within the ES spec there is no way to 
make var declarations override GSP properties.

So either var won't override them, or GSP needs to change to be part of 
the prototype chain.

Cameron proposed a specific way to do the latter.

> Are you thinking about this: ?
>
> Object.prototype<- Window.prototype<- [named props obj]<- window
>
> ...will break the web if that is truly the scope lookup. GSP needs to happen _last_ in the scope resolution for window.

The [named props obj] will still need the proxy behavior where name 
lookups on it check its proto chain first, of course.  That was the 
"does not obviate" part quoted above at the very beginning of the mail.

> In general, I'm against adding an observable object in the prototype chain for this behavior--I think the behavior should be associated with the instance.

Then you can't have var shadow GSP properties without some sort of 
changes to the ES spec.  There's simply no facility for doing that.

-Boris
Received on Thursday, 5 January 2012 18:45:27 UTC

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