Ian Hickson wrote:
Yes and Firebug has to have special code for HTMLCollection because this mistake was made in the past. Now we will have to have different special code for Storage. Rather than modeling new API on old mistakes, consider learning from the past experience and take a direction that developers will find less confusing. Pseudo-arrays with "except... this and that" makes APIs intricate and puzzling. A simpler and less ambiguous approach would be better in my opinion.On Wed, 29 Apr 2009, John J. Barton wrote:I reiterate my criticism: using a length property in this type is inconsistent with _javascript_ and with developers expectations about objects. Every time we use this object we will make pointless mistakes because the type mimics arrays only partially and we won't be able to recall which part it imitates. A simple change from |length| to a method call like getNumberOfItems() would prevent this co-incidental mimicry and make the standard better.The Storage object works like an HTMLCollection object except that you can also add items, and except that indexing by number returns the key, not the value, since otherwise there'd be no way to know which keys were being returned. I agree that it's not like an Array, but just having a "length" property doesn't mean it works like an Array -- there are lots of host objects in the DOM with "length" properties. jjb |
- Storage 'length' and enumeration John J. Barton
- Re: Storage 'length' and enumeration Ian Hickson
- Re: Storage 'length' and enumeration John J Barton
- Re: Storage 'length' and enumeration Ian Hickson
- Re: Storage 'length' and enumeration John J. Barton
- Re: Storage 'length' and enumerati... Ian Hickson
- Re: Storage 'length' and enume... John J. Barton
- Re: Storage 'length' and e... Ian Hickson
- Re: Storage 'length' and e... John J. Barton
- Re: Storage 'length' and e... Ian Hickson
- Re: Storage 'length' and e... John J Barton
- Re: Storage 'length' and e... Anne van Kesteren
- Re: Storage 'length' and e... John J Barton
- Re: Storage 'length' and e... Ian Hickson
- Re: Storage 'length' and e... John J Barton
- Re: Storage 'length' and e... Ian Hickson
- Re: Storage 'length' and e... John J. Barton
- Re: Storage 'length' and e... Sean Hogan
- Re: Storage 'length' and e... Ian Hickson
- Re: Storage 'length' and e... timeless
- Re: Storage 'length' and e... Sean Hogan