package fmlib_js

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

A node in the dom tree.

type t
val event_target : t -> Event_target.t

The node viewed as an event target.

val parent : t -> t option

The optional parent of the node.

val first : t -> t option

The optional first child of a node.

val next : t -> t option

The optional next sibling of a node.

val append : t -> t -> unit

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.

val remove : t -> t -> unit

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. *)
val replace : t -> t -> t -> unit

replace new_child old_child parent

Put new_child at the position of old_child within parent which is the parent of old_child.

Precondition: old_child must be a child of parent.

val remove_children : t -> unit

remove_children parent Remove all children from parent.

OCaml

Innovation. Community. Security.