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

Re: Older Sibling?

From: David Brownell <david-b@pacbell.net>
Date: Mon, 28 Feb 2000 15:26:21 -0800
Message-ID: <38BB041D.998865E3@pacbell.net>
To: Thomas Ashe <Thomas.Ashe@Blackbaud.com>
Cc: www-dom@w3.org
> > > Given two nodes of a common parent, identify which node
> > > precedes the other in the parent's ChildNodes nodelist.
> > >
> > > Is there such a creature in the current specs?
> >
> > You'd basically look at the nodelist yourself.  Takes a few lines
> > of code -- would you seriously expect DOM to save you the work of
> > writing such a simple subroutine?  If so, why?
> >
> 
> Dave,
> 
> DOM allows me to access a childNode directly by using the item(index) method
> off of the nodelist that is returned from childNodes, rather than walking
> the nodelist.

Right, the "list" can be implemented as an array (easy to implement
the "item" method) or as a linnked list (more awkward) or some other
data structure.


> So, I was expecting that if I had the reference to the childNode, it would
> have an index property that I would be able to use for routines like this,
> rather than having to examine the nodelist itself.
> 
> Am I really expecting too much? :-)

Perhaps.  If you got used to using it, the linked list implementation
would accumulate some bizarre costs since it'd need to recompute that
property pretty often ... but that'd be more reasonable than asking for
a specific "is this child before that one" primitive, as you'd seemed
to be suggesting!

- Dave
Received on Monday, 28 February 2000 18:26:40 GMT

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