W3C home > Mailing lists > Public > public-webapi@w3.org > April 2008

Re: [Element Traversal LC] access to element by index

From: Jonas Sicking <jonas@sicking.cc>
Date: Wed, 02 Apr 2008 03:20:10 -0700
Message-ID: <47F35DDA.90205@sicking.cc>
To: Henri Sivonen <hsivonen@iki.fi>
Cc: Boris Zbarsky <bzbarsky@mit.edu>, "Web APIs WG (public)" <public-webapi@w3.org>

Henri Sivonen wrote:
> On Apr 2, 2008, at 12:44, Jonas Sicking wrote:
>>> And to what end? To use indexing instead of list-style iteration.
>> Exactly. Something that I would imagine is quite commonly done. Note 
>> that we're not just talking iterating over a full DOM tree, we're also 
>> talking about navigating around in a DOM tree from one known specific 
>> node to another.
> It seems to me that allowing indexed access to children creates a 
> similar kind of problem that allowing indexed access to strings by 
> UTF-16 code unit has created. Allowing app code to index into platform 
> structures that are most commonly forward-iterated seems like an 
> anti-pattern in terms of what implementation constraints are placed if 
> the impression that the app developer gets is that indexing has the 
> performance properties of array access and that it is OK to write app 
> code with that assumption.

What makes you think that most users of the DOM-tree does 
forward-iteration? This is not my experience with the code I've seen. 
Rather it has been trying to get to specific nodes within a tree.

The same argument can be made for .nextElementSibling, why give 
forward-iterating access into platform structures that are most commonly 

/ Jonas
Received on Wednesday, 2 April 2008 10:21:15 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 18:10:00 UTC