W3C home > Mailing lists > Public > public-webapps@w3.org > October to December 2009

Re: childElements, childElementCount, and children (was: [ElementTraversal]: Feature string for DOMImplementation.hasFeature(feature, version)?)

From: Maciej Stachowiak <mjs@apple.com>
Date: Tue, 20 Oct 2009 13:42:20 -0700
Cc: Doug Schepers <schepers@w3.org>, WebApps WG <public-webapps@w3.org>, "www-dom@w3.org list" <www-dom@w3.org>
Message-id: <7800DB24-7E32-4222-B5FE-7E7D11B999BB@apple.com>
To: Jonas Sicking <jonas@sicking.cc>

On Oct 18, 2009, at 4:14 AM, Jonas Sicking wrote:

> On Sun, Oct 18, 2009 at 12:12 AM, Doug Schepers <schepers@w3.org>  
> wrote:
>> So, rather than dwell on an admittedly imperfect spec, I personally  
>> suggest
>> that we urge WebKit developers to implement .children  
>> and .children.length,
>> in the anticipation that this will be in a future spec but can be  
>> useful to
>> authors today.
>
> They already do. Which casts some amount of doubt on Maciejs argument
> that it was too performance heavy to implement in WebKit. :)

What I said way back in the day (about childElements) was this:
"I suggest leaving this out, because it's not possible to implement  
both next/previous and indexed access in a way that is efficient for  
all cases (it's possible to make it fast for most cases but pretty  
challenging to make it efficient for all). This is especially bad with  
a live list and an element whose contents may be changing while you  
are iterating. If all you care about is looping through once, writing  
the loop with nextElementSibling is not significantly harder than  
indexing a list."
I stand by that remark. It is indeed hard to get both indexed and  
previous/next access efficient in all cases. Of course, we are not  
going to let that stop us from interoperating with de facto standards,  
and we do our best (as for other kinds of NodeLists and  
HTMLCollections), but I'd rather not have new APIs follow this pattern.

In this particular case, I think anything that's implemented in all of  
the major browser engines should be an official standard, not just de  
facto.

Regards,
Maciej
Received on Tuesday, 20 October 2009 20:42:58 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 18:49:34 GMT