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

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

<foo>
<root id="root">
  <a>
    <b/>
  </a>
  <c/>
</root>
<visible/>
</foo>

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