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

Boris wrote:
> While I agree that having length be an own property is somewhat easier
> to implement, the fact that it would then behave totally different from
> all the other "non-live" DOM properties seems like a bad thing for
> _authors_.

In this case, I disagree, since it would make NodeList and other 
array-like collections more like arrays:

[].hasOwnProperty("length")  => true

I suspect that authors would expect the length property to behave just 
like the array index properties with which it is intimately related.
> One other note... Why is this an issue for length but not, say, item()
Conceptually, because length just seems to go with the array index 
properties.

 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; };

      David

Received on Friday, 20 May 2011 22:57:01 UTC