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

Re: Iterators and removing

From: David Peterson <david.peterson@iname.com>
Date: Sat, 4 Apr 1998 11:28:51 +1000
Message-ID: <001901bd5f69$13754820$0200a8c0@down>
To: <www-dom@w3.org>
Hi Michael,


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

<snipped other stuff>

>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 I like this idea better than the ones I suggested earlier.  A couple
of clarifying questions:

Should there be any way to test whether this has happened, other than
calling getCurrent and catching an Exception?  I guess the user will know if
this has happened and should simply take it into account.

If the removed node was the last one in the list, I assume null would be
returned and the NodeIterator would be pointing to the previous Node, which
is now the last one on the list.

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

Thanks,

David
Received on Friday, 3 April 1998 20:29:33 GMT

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