W3C home > Mailing lists > Public > www-dom@w3.org > January to March 1999

Re: Yet Another NodeList Question

From: John Cowan <cowan@locke.ccil.org>
Date: Fri, 19 Mar 1999 15:49:52 -0500
Message-ID: <36F2B870.CDE23178@locke.ccil.org>
To: DOM List <www-dom@w3.org>
Harold Poskanzer wrote:

> Since a NodeList is a "live view" into the tree, what does nextSibling do on
> items in a NodeList?

When you've fetched a Node out of a NodeList, it doesn't know it
was *in* a NodeList, so nextSibling is the Node on its right
in the tree, not its successor in the list.

> However, that makes stepping
> through items in an "abstract" NodeList (like that generated from
> getElementsByTagName) a little difficult.

Use the index method, being careful to note what you are doing
(i.e. if you are removing each node as you find it, always ask
for index(0) each time).

-- 
John Cowan	http://www.ccil.org/~cowan		cowan@ccil.org
	You tollerday donsk?  N.  You tolkatiff scowegian?  Nn.
	You spigotty anglease?  Nnn.  You phonio saxo?  Nnnn.
		Clear all so!  'Tis a Jute.... (Finnegans Wake 16.5)
Received on Friday, 19 March 1999 15:50:16 GMT

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