W3C home > Mailing lists > Public > www-dom@w3.org > October to December 1998

RE: DOM Level 1 Becomes a W3C Recommendation

From: <msabin@cromwellmedia.co.uk>
Date: Fri, 2 Oct 1998 13:37:20 +0100
Message-ID: <c=US%a=_%p=Cromwell_Media%l=ODIN-981002123720Z-2893@odin.cromwellmedia.co.uk>
To: <lehors@w3.org>, <www-dom@w3.org>
Arnaud Le Hors wrote,

> But remember that the cost of walking up the hierarchy to
> test whether the inserted node is an ancestor only applies
> when the node is already in the tree. In the case where
> the node is not in the tree, that is when it has no parent,

Not so. Consider,

  Node parent = someDoc.createElement("foo");
  Node child = someDoc.createElement("bar");

  child.appendChild(parent);   // 'parent' is not in tree
                               // so no check needed???

  someDoc.appendChild(parent); // Whoops 'someDoc' has a
                               // cycle.

I think you're confusing the case where the new child
is not in the tree (the common case) with the case
where the parent is not in the tree (very rare). It's
only in the latter that it sort of makes sense to say
that no check is needed. But it doesn't even really
make sense here, because this is just the degenerate
case where a child is being appended to the root node
of a document: naturally the check will be quick here
because, the walk from the root node to the root node
is trivial ;-)


Received on Friday, 2 October 1998 08:41:29 UTC

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