W3C home > Mailing lists > Public > www-dom@w3.org > April to June 2001

Re: Robustness of root node in traversal

From: Jonas Sicking <sicking@bigfoot.com>
Date: Mon, 21 May 2001 16:23:48 +0200
Message-ID: <00a901c0e201$a6c2c1c0$d1ee42d5@kermit>
To: <www-dom@w3.org>
Joseph Kesselman wrote:

> > The DOM2 Traversal spec defines very well what should happen
> > if the currentNode of a nodeIterator or treeWalker is moved
> > in a document or out from it. However what should happen if
> > the root node is moved in the tree?
> Or the root's ancestor. The answer in either case is basically "nothing
> happens."
> NodeIterator operates only within, and upon, the root node's subtree.
> Moving the root has no effect on the structure of the subtree, and hence
> has no effect upon iteration.
> TreeWalker operates as pure-current-node semantics. The root acts as a
> fence preventing us from traversing out of it. (Actually, it's more like a
> one-way gate; if you setCurrentNode to someplace outside the root you
> traverse back into the root but can't traverse out again.) Again, moving
> the root has absolutely no effect if currentNode is within the root's
> subtree (since the subtree moves with the root). If you've previously
> created the odd outside-the-root condition, moving the root just changes
> where the recapture will occur.
> This seemed fairly obvious to the Traversal team, so we didn't state it
> explicitly. Does it really need to be nailed down?

For the treeWalker I agree it's rather obvious, however for the nodeIterator
I would say that it wouldn't hurt with some nailing. The reason is that
implementation-wise this introduces two different behaviours for for the
reference node when an ancesor is moved out from the tree:
1. If the removed node is between the reference node and the rootnode the
reference node is moved up in the tree.
2. If the removed node is root node or an ancestor to it the referenced node
is unaffected.

But section says "If the reference node is removed from the list
being iterated over, a different node is selected as the reference node"
which isn't entierly correct.

/ Jonas Sicking
Received on Monday, 21 May 2001 10:20:59 UTC

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