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

RE: variable declarations shadowing named properties on window

From: Travis Leithead <travis.leithead@microsoft.com>
Date: Thu, 5 Jan 2012 19:12:06 +0000
To: Boris Zbarsky <bzbarsky@MIT.EDU>
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>
Message-ID: <9768D477C67135458BF978A45BCF9B38381E6E4F@TK5EX14MBXW604.wingroup.windeploy.ntdev.microsoft.com>
>-----Original Message-----
>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
>>>> 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.

I thought Cameron proposed another alternative, which I much prefer over adding another object to the prototype chain:

>From: Cameron McCormack [mailto:cam@mcc.id.au]
>If we want var statements without a variable assignment to shadow named 
>properties, then we can't keep [[GetOwnProperty]] returning property 
>descriptors for them while [[HasProperty]] returns true for them, 
>without violating the ECMAScript spec.
>We could either make [[HasProperty]] return false for named properties 
>on window despite [[GetOwnProperty]] returning a property descriptor. 
>Or, we could make the window object have a custom [[GetProperty]] 
>instead of [[GetOwnProperty]], so that [[HasProperty]] returns false and 
>[[GetOwnProperty]] returns undefined, while fetching the property off 
>the object still gives you the named property value.

Among those options, I believe IE implements a proxy hook for both [[GetProperty]] and [[HasProperty]] -- (though our internal proxy hooks don't line up exactly with these ES 5 spec notions, they are similar in concept). Since we only need one or the other to describe the desired behavior in WebIDL, I'd prefer to see [[HasProperty]] customized. This could even allow other WebIDL concepts like [Replaceable] and [OverrideBuiltins] to be spec-simplified, I think.
Received on Thursday, 5 January 2012 19:12:42 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 17:14:05 UTC