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

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

From: Doug Schepers <schepers@w3.org>
Date: Fri, 28 Mar 2008 13:00:12 -0400
Message-ID: <47ED241C.10803@w3.org>
To: "Web APIs WG (public)" <public-webapi@w3.org>

Hi, Jonas-

I addressed Daniel's comments in another email, but I wanted to address 
your additional points specifically.

Jonas Sicking wrote (on 3/28/08 12:23 PM):
> I agree with Daniel here. I'm not really following your argument. Are we 
> trying to keep compatibility with the SVG spec here? Is the interface as 
> designed now 100% compatible with SVG?

SVG dropped Element Traversal from its spec, and gave it to the WebAPI 
WG to spec out, so it only references it, thus there can be no 
incompatibilities per spec.

In pragmatic terms, UAs, libraries, and related JSRs which focus on SVG 
Tiny 1.2 have already adapted to the only change I introduced, 
'childElementCount'.  So, there are no incompatibilities by 
implementation either.  (See my other email for the wisdom of waiting 
for spec stability.)

> If we're not 100% compatible with SVG, why would they oppose an 
> improvement like the suggested one?

Indeed, I did introduce a nodeList in an earlier version of the spec to 
add this functionality, but was convinced to remove it by general 
consensus of this WG and by merits of argument.  There are pros and cons 
to each approach, but within the scope of the larger context of 
available Web APIs, I think the more compelling argument is to leave the 
spec as is.

> If we don't provide a way to grab elements by index I don't really see a 
> purpose of the childElementCount attribute.

The use for 'childElementCount' is laid out in the spec, most explicitly 
in one of the examples [1], and in the introduction:

"The DOM Level 1 Node interface also defines the childNodes attribute, 
which is a live list of all child nodes of the node; the childNodes list 
has a length attribute to expose the total number of child nodes of all 
nodeTypes, useful for preprocessing operations and calculations before, 
or instead of, looping through the child nodes. The ElementTraversal 
interface has a similar attribute, childElementCount, that reports only 
the number of Element nodes, which is often what is desired for such 

Though the example uses HTML, this is really a more common scenario in 
SVG, where more of the content is element-based, rather than text-based. 
  Speaking as an author of many SVG Webapps and a contributor to several 
SVG script libs, knowing the number of child elements is a really common 
need; index-based access is less needed, and can be effected by other 

[1] http://www.w3.org/TR/ElementTraversal/#example-3.2

-Doug Schepers
W3C Team Contact, SVG, CDF, and WebAPI
Received on Friday, 28 March 2008 17:00:45 UTC

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