Re: indexed properties on NodeLists and HTMLCollections

On 6/22/11 11:37 PM, Cameron McCormack wrote:
>> This will likely make definition of expandos somewhat slow, but I
>> suppose that's ok; that's a rare case.
>
> Can you explain why that would be?

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.

> 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.  ;)

-Boris

Received on Thursday, 23 June 2011 04:01:17 UTC