Ian Hickson wrote:
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.
  
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.

jjb



Reply via email to