W3C home > Mailing lists > Public > www-dom@w3.org > July to September 2004

Traversal clarification: rootNode has no visible content descendants. .. siblings?

From: <ajvincent@juno.com>
Date: Sun, 12 Sep 2004 20:10:19 GMT
To: www-dom@w3.org
Message-Id: <20040912.131045.23867.783645@webmail19.lax.untd.com>

Some time ago, I noticed in Mozilla what I perceived to be a bug.  Given the following:

<root id="root">

If I had a NodeFilter like this:

aFilter = {
  acceptNode: function(aNode) {
    if (aNode.localName == "visible") {
      return NodeFilter.FILTER_ACCEPT;
    return NodeFilter.FILTER_SKIP;

and a TreeWalker like this:

var root = document.getElementById("root")
var walker = document.createTreeWalker(root, NodeFilter.SHOW_ELEMENT, aFilter, true);

var aNode = walker.nextNode();

I had thought for a very long time that aNode would be null under this testcase.  However, aNode does return the <visible/> element.

I thought this was a bug in Mozilla, until I started checking the DOM-2 Traversal Recommendation... and as hard as I went through it, I could not find anything in the Recommendation that said it was wrong!

The key word in the specification's definitions appears to be the word "upward".  Not "outside".  As in, for TreeWalker.nextNode:

"...if the search for nextNode attempts to step upward from the TreeWalker's root node..."

Please advise:  was this the intent of the specification, or is this an errata in the specification, and a bug in the implementation?

Alexander J. Vincent
Vallejo, CA, U.S.A.

Get your name as your email address.
Includes spam protection, 1GB storage, no ads and more
Only $1.99/ month - visit http://www.mysite.com/name today!
Received on Sunday, 12 September 2004 20:12:32 UTC

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