Re: Hello and NodeIterator Revisited

Eric Vasilik <ericvas@microsoft.com> writes:

> Consider the '*' character as the 'point' in the document.  Even though
> there is an iterator underneath the bold tag, the DOM would report that
> there are zero children for the bold.  Now, if one were to create and insert
> a node (say, and italic node) as a new child of the bold node, you have two
> options for updating the iterator:
> 
> 	X<B>*<I></I></B>Y, or
> 	X<B><I></I>*</B>Y
> 
> The iterator could go to the left of the newly inserted node, or to the
> right of it.  

I would say that the Iterator on the left is the correct way.  I am
assuming they are calling Node.insertBefore.  If the refChild is null,
which it would be if they were inserting into a Node with no present
children, it is supposed to append it at the end of the current list.
So I would put it after the iterator point, even tho it's the only
item in the list.

I suppose this could be interpreted different ways.

> Also, given my original example, what would happen to the iterator if the
> bold node were removed from the tree.  Again, you have two options:
> 
> 	X*Y, or
> 	XY
> 
> Stated in words: should the iterator remain in the document in which it was
> inserted, or should it be associated with the subtree in which it currently
> lives, and move with that subtree?

I would imagine it would stay within it's subtree.  The NodeIterator
doesn't seem to know that the tree or subtree exists.  It just talks
about the current Node's contents.  The TreeIterator is aware of
parents and can navigate between different levels in the tree, so I
would assume that it would stick with the subdoc it is in, and if that
is removed, it would go with those nodes and now it's ability to
navigate would be bounded to those nodes in the subtree.  Makes it a
little easier to deal with security issues, just return a TreeIterator
to a subdoc that has been ripped out of the whole document.  let them
make their changes and then push it back into the major tree.

Received on Tuesday, 5 May 1998 16:59:18 UTC