RE: variable declarations shadowing named properties on window

>-----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
>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.


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