W3C home > Mailing lists > Public > www-dom@w3.org > October to December 2009

Re: childElements, childElementCount, and children

From: Laurens Holst <laurens.nospam@grauw.nl>
Date: Thu, 22 Oct 2009 13:02:39 +0200
Message-ID: <4AE03BCF.60205@grauw.nl>
To: Jonas Sicking <jonas@sicking.cc>
CC: Doug Schepers <schepers@w3.org>, "www-dom@w3.org list" <www-dom@w3.org>
Op 21-10-2009 12:27, Jonas Sicking schreef:
> Comment nodes are fairly rarely used. A webpage that doesn't want to
> worry about if comment nodes are going to be included in .children or
> not can simply avoid using comment nodes in those parts of the DOM.
> And an implementation that simply wants to iterate over all child
> elements can simply check for comment nodes and skip them as
> appropriate. And in the case where you're only looking for a certain
> set of element names, you don't even need to make extra effort to skip
> comments.

I really really don’t get what the benefit is of using .children over 
.childNodes if you still have to filter on node type for .children.

If you have so much control over the DOM that you can dictate that there 
be no comment nodes (e.g. when the DOM is dynamically created through 
script or off a template), by the same argument you can also dictate 
that there are no white space text nodes, or access the DOM with indexes 
that take their locations into account. Thus, again, there is no benefit 
of .children over .childNodes.


~~ Ushiko-san! Kimi wa doushite, Ushiko-san nan da!! ~~
Laurens Holst, developer, Utrecht, the Netherlands
Website: www.grauw.nl. Backbase employee; www.backbase.com

Received on Thursday, 22 October 2009 11:03:18 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 20 October 2015 10:46:15 UTC