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

RE: Hello and NodeIterator Revisited

From: Eric Vasilik <ericvas@microsoft.com>
Date: Tue, 5 May 1998 21:43:11 -0700
Message-ID: <2FEED299C092D1118B3100805F6F41BD0444B8DE@RED-MSG-09>
To: www-dom <www-dom@w3.org>
>> 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
>> 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.

What I have done is (when the insertion of the italic takes place) to query
a propery of the iterator (I call it gravity) which has values left and
right.  Iterators with left gravity scoot to the left of any new context,
and iterators with right gravity scoot to the right of any new content.  Of
course, this querying of gravity on iterators only needs to take place when
it is ambiguous as to which way the iterator should go.  This way, whoever
created the iterator can determine the behavior of the iterator in the
presence of a changing document.

>> 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
>> inserted, or should it be associated with the subtree in which it
>> 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.

I agree.

- Eric
Received on Wednesday, 6 May 1998 00:43:14 UTC

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