Re: childElements, childElementCount, and children

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.

~Laurens

-- 
~~ 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