Re: ElementTraversal spec draft

* Charles McCathieNevile wrote:
>@@issue: should we add a childElements attribute
>that returns a list of elements?

No! You can easily do this with

  for (child = element.firstElementChild;
       child;
       child = child.nextElementSibling)
    array.push(child);

  for (var i = 0; i < array.length; ++i)
    ...

I do not see why you would do that though. Further, you can about as
easily do this using DOM XPath, XPath selectNodes, the CSS Query API,
DOM Level 2 Traversal, you can in fact just use Core like

  for (var i = 0; i < element.childNodes.length; ++i)
    if (element.childNodes[i].nodeType == 1)
      ...

well you would really use

  for (child = element.firstChild;
       child;
       child = child.nextSibling)
    if (child.nodeType == 1)
      ...

Counting is trivially implemented on top of these, or you can just
use XPath "count(*)". I understand a primary concern why SVG Tiny 1.2
did not have many of the DOM Core features is because the NodeList
interface was regarded as expensive. And having childNodes live and
childElements not live would add considerable confusion. No need for
an alias for element.selectNodes("*") and element.cssQuery("*").

As a comment on the draft, you have to define how the method behave
in case of unexpanded entity references and entity replacement markup.
I've explained this in a little bit more detail on www-svg at some
point.
-- 
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 Thursday, 15 March 2007 19:27:01 UTC