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

Re: variable declarations shadowing named properties on window

From: Cameron McCormack <cam@mcc.id.au>
Date: Fri, 06 Jan 2012 14:08:27 +1100
Message-ID: <4F0665AB.3080501@mcc.id.au>
To: Boris Zbarsky <bzbarsky@MIT.EDU>
CC: Allen Wirfs-Brock <allen@wirfs-brock.com>, Ojan Vafai <ojan@chromium.org>, Travis Leithead <travis.leithead@microsoft.com>, "public-script-coord@w3.org" <public-script-coord@w3.org>, Ian Hickson <ian@hixie.ch>, Jeff Walden <jwalden@mit.edu>
Boris Zbarsky:
> In any case, the updated text says that if HasBinding returns true then
> the implementation should call [[GetOwnProperty]] on the global. If this
> returns undefined, then [[DefineOwnProperty]] is called on the global
> with the property descriptor: {[[Value]]: undefined, [[Writable]]: true,
> [[Enumerable]]: true , [[Configurable]]: configurableBindings }.
>
> So now to make var shadow some property that property needs to either
> return false from HasBinding or return undefined from [[GetOwnProperty]].

Only if we want to keep them on window.  If we're happy to move them to 
the prototype then we're safe, I believe.

> Cameron, can GSP properties return undefined from [[GetOwnProperty]] but
> still do what they should for window.foo and bareword lookups without
> other things elsewhere breaking?

They can for window.foo but not for bareword lookups.  window.foo will 
do a [[Get]], and we could have that return the frame while 
[[GetOwnProperty]] returns undefined.  That breaks barewords, though, 
which definitely do use HasBinding and so [[GetOwnProperty]] to 
determine if the reference can be resolved or not.
Received on Friday, 6 January 2012 03:09:47 UTC

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