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

Re: Iterators and removing

From: Mike Champion <mcc@arbortext.com>
Date: Fri, 3 Apr 1998 09:30:00 -0500
Message-Id: <98Apr3.092808est.26882@thicket.arbortext.com>
To: www-dom@w3.org
At 06:21 AM 4/2/98 -0500, Axel Wienberg wrote:
>
>Hi,
>
>I've got a question on the behaviour of NodeIterators.  What is supposed to
>happen if the current node of an iterator is removed from its parent?
>
>The method toNext() of NodeIterator is defined as follows:
>
>   This method alters the internal state of the iterator such that the
node it
>   references is the next in the sequence the iterator is presenting relative
>   to the current position.
>
>But now the node is no longer part of the sequence represented by the
iterator.
>This case actually occurs if you want to conditionally remove the children of
>some node.
>
>It gets even more confusing if you reinsert the node at a different
position as
>a child of the same parent: Does the Iterator move along with its node?  Or
>what if you insert it as a child of an entirely different parent?
>
>

We discussed this in the IG recently; I'm not sure if we reached a
consensus.  My position is that if one removes a node that an iterator
points to, the "current" node becomes undefined and the getCurrent() method
should throw an exception, and toNext() and toPrevious() would return the
values that would have been returned had the node not been deleted.  In
other words, I imagine the iterator pointing to the empty spot where the
current node WAS; since there is no node there, "current" is undefined, but
next and previous are.

I think the alternatives are confusing for users and challenging for
implementors, and don't add anything in the way of conceptual integrity.





Mike Champion
Received on Friday, 3 April 1998 09:29:37 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 22 June 2012 06:13:45 GMT