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

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]] at 
http://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).

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.

> (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.

-Boris

Received on Thursday, 12 September 2013 01:08:22 UTC