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

Re: Hello and NodeIterator Revisited

From: Don Park <donpark@quake.net>
Date: Tue, 5 May 1998 14:04:24 -0700
Message-ID: <001c01bd7869$64d769a0$2ee044c6@arcot-main>
To: "www-dom" <www-dom@w3.org>
> X<B>*</B>Y
>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
>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.

In FREE-DOM, first child is appended and point-nodes are prepended.  This
means that real nodes will slide to right while fake nodes slide to the
left.  I am not sure if this is correct behavior or whether there is such
thing as correct behavior but it favors forward iteration.

I am comfortable with the behavior (besides nine out of ten professional
iterators will recommend forward iteration ;-).

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

This is a concern only for TreeIterator since position node is part of the
destroyed node's content.  As far as TreeIterator is concerned, it does not
matter whether the position pops out or not because iterator's context will
change without notifying the iterator.

Actually its the code that uses the iterator that will be in trouble because
even if an exception is thrown by the iterator (this can be done by iterator
checking to see if the position's parent has either changed or null) code
that uses the iterator will be confused and have a difficult time finding
its place again.

It would be very difficult to write something like an XSL processor over DOM
if elements keep disappearing during pattern search.  If a part of a pattern
being matched is removed, should the action still be fired?

So we have two problems: behavior ambiguity and usage complexity

Pass me that bottle of Tylenol,

Don Park

PS: If my concept of a paragraph seem to be that of a long sentence, it is
because I prefer to write 'reply-ready' messages.
Received on Tuesday, 5 May 1998 17:11:24 UTC

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