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

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

From: Bjoern Hoehrmann <derhoermi@gmx.net>
Date: Fri, 28 Mar 2008 16:47:24 +0100
To: Daniel Glazman <daniel.glazman@disruptive-innovations.com>
Cc: "Web APIs WG (public)" <public-webapi@w3.org>
Message-ID: <244qu3l5ol3r7elnc6ujq1ugg25mihl3ev@hive.bjoern.hoehrmann.de>

* Daniel Glazman wrote:
>1. congrats for this spec, I love it ; I can't count how many times in
>    page or chrome script I am filtering out nodes that are not element
>    nodes.
>2. the ElementTraversal interface has a |childElementCount| attribute
>    but misses access to an individual childElement based on its index.
>    That would be really useful. Two solutions here :
>    a. you remove the childElementCount attribute in favor of a
>         readonly attribute NodeList    childElements;
>       and that NodeList has all we need

It was the SVG Working Group that originally came up with the interface
and they, as I understand it, decided against having any NodeList in the
SVG Tiny 1.2 DOM. They rather introduced the interface to allow imple-
mentations to discard some nodes like comments and text nodes with only
white space while keeping compatibility with implementations that keep
them. I would imagine they would be unhappy with such a change.

>    b. you add
>         Node    item(in unsigned long index);
>       but that is not really consistent with the existing way of
>       querying list of nodes.
>    My very strong preference goes to solution a.

At the least you would need a different name as this would go on all
element nodes and you would probably run into name clashes quickly, and
confuse authors (NodeList.item vs. Element.item for example). However,
you could also just use XPath, or Selectors, or one of the many other
methods for this particular case, I don't think this addition is needed.
Björn Höhrmann · mailto:bjoern@hoehrmann.de · http://bjoern.hoehrmann.de
Weinh. Str. 22 · Telefon: +49(0)621/4309674 · http://www.bjoernsworld.de
68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/ 
Received on Friday, 28 March 2008 15:48:12 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:16:25 UTC