Re: Robustness of root node in traversal

> 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 could
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?

______________________________________
Joe Kesselman  / IBM Research

Received on Monday, 21 May 2001 09:29:39 UTC