W3C home > Mailing lists > Public > whatwg@whatwg.org > September 2013

Re: [whatwg] [[GetOwnProperty]] for named properties of the Window object

From: Gavin Barraclough <barraclough@apple.com>
Date: Thu, 12 Sep 2013 11:36:53 -0700
Message-id: <DED137DB-3BD8-4298-A427-FBF2BC33EEE5@apple.com>
To: Boris Zbarsky <bzbarsky@MIT.EDU>
Cc: whatwg@lists.whatwg.org
On Sep 11, 2013, at 6:07 PM, Boris Zbarsky <bzbarsky@MIT.EDU> wrote:

> On 9/11/13 6:05 PM, Gavin Barraclough wrote:
>> Interesting, I had just assumed this was okay  is it not spec-compliant for Window.prototype to be a named properties object?
> 
> No, it's not.  The spec defines exactly what the prototype chain looks like here.  See the definitions of [[Prototype]] athttp://dev.w3.org/2006/webapi/WebIDL/#named-properties-object and http://dev.w3.org/2006/webapi/WebIDL/#interface-prototype-object (item 1 at the latter).

Ah, got it, thanks.  Id only spotted the partial description in http://dev.w3.org/2006/webapi/WebIDL/#Global

> So the chain by default is window -> Window.prototype -> named properties object -> EventTarget.prototype -> Object.prototype.
> 
> This allows specification of the named properties object without having to worry about weird interactions with name collisions on Window.prototype, whether with properties it has by default or properties someone wants to add to it.  Note that the named properties object does not allow [[DefineOwnProperty]], so if it were Window.prototype then you wouldn't be able to add any properties to Window.prototype!
> 
>> I believe these properties are implemented as shadowable in the same way as [Replaceable] properties
> 
> [Replaceable] properties need the magic they have because they're accessor properties, which normally can't be shadowed via assignment.
> 
> But named properties on the named properties object are value properties, so simply making them writable allows them to be shadowed. In fact, that's the only way to make them shadowable.

Got it.

>> (and then assume a modified behaviour of ES [Put] for properties with this attribute, to permit overwrite even if readonly).
> 
> I don't think a special [Put] is needed if the properties aren't readonly.

Hmmm, interesting.  I was thinking that in the case that a shadowing property was put to the named property object itself, then deleted, this needed further description (as the old property reappears)  but I guess that it just covered by the current spec [[GetOwnProperty]] implementation.

Many thanks,
Gavin
Received on Thursday, 12 September 2013 18:37:16 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 17:00:09 UTC