Configuration options for automatic node insertion.

interface NodePosition {
    position?: "first" | "last" | "only" | "replace" | "before" | "after";
    referenceNode: HTMLElement;
}

Properties

position?: "first" | "last" | "only" | "replace" | "before" | "after"

Inserts the node at the specified position. The default value is "last".

  • "first": as the first child of referenceNode
  • "last": as the last child of referenceNode
  • "only": as the only child of referenceNode (all other children are removed)
  • "replace": replaces a given referenceNode with the node
  • "before": the new node is inserted before referenceNode (as its neighbor)
  • "after": the new node is inserted after referenceNode (as its neighbor)
referenceNode: HTMLElement

If referenceNode is specified, the new element will be automatically inserted relative to the specified node. By default, the new node will be inserted as the last child of referenceNode.

Use the position flag to customize the insertion behavior.