W3C home > Mailing lists > Public > www-dom@w3.org > July to September 1998

Re: parentNode

From: Stephen R. Savitzky <steve@crc.ricoh.com>
Date: 28 Jul 1998 09:37:19 -0700
To: keshlam@us.ibm.com
Cc: www-dom@w3.org
Message-ID: <qc90le9bk0.fsf@gelion.crc.ricoh.com>
keshlam@us.ibm.com writes:

> I think I second Steve on this one. Nothing wrong with a null parent
> pointer; it's easier for code to deal with that than to deal with an
> implicit non-null.

There's actually a good reason to _require_ null as the parent of an orphan
node, and that is so that one can reliably determine whether a node is an
orphan (and therefore safe to insert into a tree without cloning).

It would be sufficient, though, to specify that orphan nodes have an
unambiguously-determined value for their parent, since in some languages
it's better to have an actual object as the parent than a null.

Another possibility would be to throw an exception when trying to obtain the
parent of an orphan node, but this would be less efficient and lead to
clumsier code.  Far better to simply require orphan nodes to have null as
their parent. 

The third possibility is to add an "isOrphan()" method.  This may be best,
since it avoids even looking at the parent, which might (according to the
present spec) have to create a fragment.

-- 
 Stephen R. Savitzky   Chief Software Scientist, Ricoh Silicon Valley, Inc., 
<steve@rsv.ricoh.com>                            California Research Center
 voice: 650.496.5710   fax: 650.854.8740    URL: http://rsv.ricoh.com/~steve/
  home: <steve@starport.com> URL: http://www.starport.com/people/steve/
Received on Tuesday, 28 July 1998 12:33:18 GMT

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