- From: David Flanagan <dflanagan@mozilla.com>
- Date: Fri, 20 May 2011 15:56:32 -0700
- To: public-script-coord@w3.org, Boris Zbarsky <bzbarsky@MIT.EDU>
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