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

Re: Move length property to the set of supported property indicies?

From: Boris Zbarsky <bzbarsky@MIT.EDU>
Date: Fri, 20 May 2011 19:12:51 -0400
Message-ID: <4DD6F573.4040304@mit.edu>
To: David Flanagan <dflanagan@mozilla.com>
CC: public-script-coord@w3.org
On 5/20/11 6:56 PM, David Flanagan wrote:
> I suspect that authors would expect the length property to behave just
> like the array index properties with which it is intimately related.

It doesn't behave like them in browsers now, though (e.g. it's never 
dynamically created or destroyed).

> Conceptually, because length just seems to go with the array index
> properties.

I'm not sure I agree, but...

>  From an implementation standpoint, once I have a proxy that handles the
> array index properties, I can implement item(n) like this without having
> to use a WeakMap:
>
> NodeList.prototype.item = function(n) { r = this[n]; if (r===undefined)
> return null; else return r; };

This implementation is incorrect, for what it's worth, in all sorts of 
ways, but I expect you knew that...

With enough error-checking on n, I guess this could work.  How are you 
planning to do HTMLCollection?

-Boris
Received on Friday, 20 May 2011 23:13:21 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 8 May 2013 19:30:03 UTC