- From: <keshlam@us.ibm.com>
- Date: Fri, 16 Oct 1998 14:15:38 -0400
- To: www-dom@w3.org
>This does mean, however, that you cannot use firstChild and looping on >nextSibling to traverse the children of a node, I think. You can use it at risk if the tree is being edited. If the node you're asking for its nextSibling was moved elsewhere in the tree, or removed from the tree, or has more nodes added after it, its nextSibling will be taken relative to its new location. If all that's happening is appends, though, nextSibling will either point to the right thing or be null meaning you've reached the end of the document. If you think appending is still be going on, you have to re-query that nextSibling reference if/when more data might have become available... but that's the application's responsibility. Of course similar caveats apply to NodeList. As insertions and deletions occur, trying to go from node i to node i+1 may find the expected next node, may skip nodes, or may skip back to an already-processed node. If all that's happening is appends, item(i+1) will either point to the right thing or be null meaning you've reached the end of the document. If you think appending is still be going on, you have to re-query item(i+1) if/when more data might have become available... but that's the application's responsibility. Much of a muchness. Gratuitous grumbling: NodeList's only advantage over an iterator is that even users who can't understand "next" ought to be able to deal with "+1". Whether that's a community worth catering to, rather than educating or addressing via a higher-level tool, is something we'll never agree on. ______________________________________ Joe Kesselman / IBM Research Unless stated otherwise, all opinions are solely those of the author.
Received on Friday, 16 October 1998 14:01:20 UTC