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

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

From: Daniel Glazman <daniel.glazman@disruptive-innovations.com>
Date: Tue, 01 Apr 2008 17:41:56 +0200
Message-ID: <47F257C4.8030803@disruptive-innovations.com>
To: Henri Sivonen <hsivonen@iki.fi>
Cc: "Web APIs WG (public)" <public-webapi@w3.org>

Henri Sivonen wrote:

> How often do people pick a single child by index (with a number know a 
> priori) instead of iterating over children and testing each one for an 
> interesting trait?

Let me turn the problem differently : NodeList and NamedNodeMap are the
normal answers when we query a list of nodes, for instance through
Document.getElementsByTagName() or Element.childNodes, why should this
behave differently and why should the DOM be inconsistent here ?
I must add that XPath also allows to select the nth child of a given
element, that Selectors can do the same through
|#myParent > :nth-child(n)|.

Apparently querying the nth element child of an element is NOT that
uncommon:

http://www.mail-archive.com/discuss@jquery.com/msg20124.html
http://groups.google.com/group/jquery-en/browse_thread/thread/f49c09bb901f7aa6
http://tinyurl.com/2wsxlc
http://www.xml.com/pub/a/2007/01/24/whats-new-in-prototype-15.html?page=4
and the list is much longer.


</Daniel>
Received on Tuesday, 1 April 2008 15:42:35 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 1 April 2008 15:42:35 GMT