W3C home > Mailing lists > Public > public-script-coord@w3.org > April to June 2011

Re: indexed properties on NodeLists and HTMLCollections

From: Boris Zbarsky <bzbarsky@MIT.EDU>
Date: Thu, 23 Jun 2011 00:00:45 -0400
Message-ID: <4E02BA6D.6010101@mit.edu>
To: David Flanagan <dflanagan@mozilla.com>, Jonas Sicking <jonas@sicking.cc>, Allen Wirfs-Brock <allen@wirfs-brock.com>, public-script-coord@w3.org
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

This archive was generated by hypermail 2.3.1 : Wednesday, 8 May 2013 19:30:03 UTC