Node.insert(idx, child) is not sufficient for building DOM.

Specification for Node is missing appendChild call, I believe.
If you want to add a child at the end of the current children of the node,
there are two ways to do it:
1) node.getChildren().append(newChild)
2) node.insert(100000, newChild)

The problem in first case is how and when to set the parent up. It is
evident to me that when child is set, it should have its(child's) parent
set to the proper value. Otherwise, traversal would be all messed up.
The only good way I see is to be able to set parent relation properly is
when node itself is called to set its child.  Alternatively, NodeList can
have some kind of observer/owner to call back on when it is modified, but
that is ugly. 

In the second case, the problem is choosing an index. If a fixed number is
used, it is not robust, as theoretically any number can be reached and the
child would be inserted in the wrong place. If the number is _not_ fixed
that it should depend on current number of children, the only way to get
which is to do node.getChildren().getLength() in which case it is already
too tempting to do case 1).

There is also a general problem with being able to modify children()
NodeList behind the back of the parent node. Maybe the NodeList should
have a read/only counterpart? Or maybe children() should return
NodeEnumerator instead?

Regards,
  Alex.

Ps. About a week ago I send a long mail with interesting (IMHO) questions.
    Looks like nobody liked them. :-{ Or maybe DOM is on a _very_ low
    priority standing at w3c?

Received on Saturday, 25 October 1997 23:57:14 UTC