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 18:39:04 +0000
To: Cameron McCormack <cam@mcc.id.au>, Boris Zbarsky <bzbarsky@MIT.EDU>
CC: 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: <9768D477C67135458BF978A45BCF9B38381E6D83@TK5EX14MBXW604.wingroup.windeploy.ntdev.microsoft.com>
>-----Original Message-----
>From: Cameron McCormack [mailto:cam@mcc.id.au]
>Boris Zbarsky:
>> What Gecko actually uses is more like this, I believe:
>> Object.prototype <- [named props obj] <- Window.prototype <- window
>> 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...
>> 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, it's a special proxy behavior.

>Even though there's only one instance of Window that inherits from a
>given Window.prototype, it makes slightly more sense to me to have the
>instance-specific named properties object closer to the instance, before
>inheriting from Window.prototype.
>I think we can just trigger this "add an extra object in the proto
>chain" based on [ReplaceableNamedProperties], so no changes to HTML's
>IDL would be needed.

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. For example, the HTML5 spec itself has some <span id="document"> which would then shadow the actual document getter on Window.prototype.

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.
Received on Thursday, 5 January 2012 18:40:41 UTC

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