W3C home > Mailing lists > Public > public-script-coord@w3.org > April to June 2011

[WebIDL] Indexed properties and [[Extensible]]

From: David Flanagan <dflanagan@mozilla.com>
Date: Wed, 25 May 2011 12:15:36 -0700
Message-ID: <4DDD5558.8080107@mozilla.com>
To: public-script-coord@w3.org
4.5.2 indicates that indexed properties won't be added to an object if 
its [[Extensible]] attribute is false.  I take this to mean that 
conforming objects will work like regular JavaScript objects for 
Object.preventExtensions() as well as Object.seal() and 
Object.freeze().  Is this the intent?

Let's take NodeList as a concrete example, keeping in mind that DOM Core 
requires that the childNodes property of a Node always returns the same 
NodeList object and that that object is live:

var div = document.createElement("div");
var kids = div.childNodes;  // a NodeList
kids.freeze()                       // This should work, right?
// I think this should succeed despite the freeze() above, right?
div.childNodes[0]               // => the original text node "test"
div.childNodes[1]               // => undefined because of freeze
div.childNodes.length;       // But this is 2, right?
div.childNodes.item(1);      // What does this return?

This seems like a nasty can of worms to me.  A simpler approach would be 
to require an implementation to throw a TypeError on any attempt to set 
[[Extensible]] to false on an object that has an indexed getter.  It 
just doesn't make sense to be able to freeze a live collection.

(Does WebIDL need to make a distinction between interfaces that are live 
and those that are not?  Should there be a [Freezeable] attribute for 
non-live interfaces with indexed getters?)

Received on Wednesday, 25 May 2011 19:16:05 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:37:44 UTC