On Sep 11, 2013, at 6:07 PM, Boris Zbarsky <[email protected]> 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.  I’d 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

Reply via email to