Library
Module
Module type
Parameter
Class
Class type
A node in the dom tree.
val event_target : t -> Event_target.t
The node viewed as an event target.
apppend child parent
Append child
to the end of the children of parent
If child
is already a child of another node, it is removed from the other node. A node can be a child of only one parent node.
remove child parent
Remove child
from parent
Precondition: child
must be a child of parent
.
If you are not sure that child
belongs to parent
, get parent child
and check (by physical equality ==
) that the computed parent and parent
are the same.
Procedure to remove all children from a node:
let rec remove_children (node: t): unit =
match first node with
| None ->
()
| Some child ->
remove child node;
remove_children node (* tail recursion, compiled to a
javascript loop. *)