- From: Deke Smith <deke@tallent.com>
- Date: Wed, 4 Nov 98 09:36:57 -0600
- To: "Don Park" <donpark@quake.net>, "DOM Lis" <www-dom@w3.org>
Don Park, donpark@quake.net said on 11/4/98 1:10 AM:
>>The return value should be the Node added. Since, after being inserted
>>into another Node the DocumentFragment no longer exists, what is
>>returned?
>
>
>Return DocumentFragment. DocumentFragment still exists even though its
>contents have been moved to another node.
>
>Don
>
>
I am trying to understand this. I am trying to create an implementation
and trying to make it fit with the specs. I have very little patience
with discussions about semantics, but this may be one of the few times it
is appropriate. Lurking on this list, I have noticed that many of the
threads can go back and forth about the subtleties the spec's meaning. I
appreciate the patience of everyone.
With that said, I am forging through the spec while creating an
implementation. Here's a little more detailed explanation of why having
Node.insertNode() return a DocumentFragment Node after inserting a
DocumentFragment Node is confusing to me.
If the DocumentFragment were inserted into a Node, it would be a Child of
that Node. But according to the spec (from the description of Node
attributes):
"parentNode
"The parent of the given Node instance. All nodes, except Documents and
DocumentFragments, have a parent."
And from the description of the insertChild method:
"If newChild is a DocumentFragment object, the entire contents of the
document
fragment are moved into the child list of this node."
Here's the implications of this as I understand it:
Before being inserted, a DocumentFragment's children will point to the
DocumentFragment as their parentNode. After the DocumentFragment has been
inserted, its children would point to the Node the DocumentFragment was
inserted to as their parentNode. The DocumentFragment would not be
included in the child list of the Node it was inserted into, but the
DocumentFragment's children would be.
This supposes that a Node cannot be in the child list of two different
Nodes.
Also from the spec under the description of the insertChild method:
"Note: After a successful call to this
method, the newChild node will be removed from its previous position in
the tree, and all
NodeLists that reference the child list of this object, and previous and
next sibling
attributes of some children, must be updated."
The old DocumentFragment no longer exists and a new Document Fragment
cannot be placed as a child of a Node. What are the characteristics of a
DocumentFragment if that is what is returned? The attributes childNodes,
parentNode, previousSibling, and nextSibling would all be null. The
returned value from Node.insertNode() would not reflect what was actually
inserted.
Again, thanks for your patience as I seek Ultimate Understanding of the
spec.
Deke
-----------------------------------------------------------------
Deke Smith
Tallent Communications Group, Brentwood TN
deke@tallent.com, 615-661-9878
-----------------------------------------------------------------
" The best way to predict the future is to invent it. "
- Alan Kay
Received on Wednesday, 4 November 1998 10:37:08 UTC