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 14:15:20 -0500
Message-ID: <4F05F6C8.7090705@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 2:12 PM, Travis Leithead wrote:
> 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.

It's not entirely clear to me whether this works for the window in 
particular, because as far as I can tell the bareword lookup algorithm 
in ES relies on [[HasProperty]] before ever calling [[Get]].  I could 
well be wrong on that, though; I don't follow that section of the spec 
very well.

Received on Thursday, 5 January 2012 19:23:22 UTC

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