Re: indexed properties on NodeLists and HTMLCollections

Boris Zbarsky:
> Defining an expando needs to make sure that there is no element in the
> collection that has that name/id.  But that information is maintained
> lazily, so typically the expando definition will need to first make sure
> the collection's state is up to date and then go and check whether any
> of the items in the collection have that name or id.  This last bit
> could be fast if the collection maintains some sort of hashtable mapping
> names to elements, or it might involve checking each node in the collection.

OK, understood.

> >Also, if there’s a scheme that isn’t slow that you would prefer (and has
> >the desired compatibility characteristics), I’m happy to consider
> >changing to that.
> 
> I'm not quite sure there is...  I haven't thought of one yet, at least.
> 
> I assume letting property definitions define the property but have the
> getter keep shadowing it as long as something in the collection has that
> name, is too crazy, for example.  ;)

I wondered about that approach.  I think it isn’t too crazy; it at least
features a different kind of consistency. :)  The current design is only
slightly less surprising.

-- 
Cameron McCormack ≝ http://mcc.id.au/

Received on Thursday, 23 June 2011 04:26:55 UTC