Skip to content

globals/Node.prototype

Mocks of the child-management and element-creation helpers Obsidian adds to Node.prototype.

Function Description
appendText Appends a text node to this node.
createDiv Creates a <div> and appends it to this node, as createEl does.
createEl Creates an element and appends it to this node, or prepends it when o.prepend is set.
createSpan Creates a <span> and appends it to this node, as createEl does.
createSvg Creates an SVG element in the SVG namespace and appends it to this node, or prepends it when o.prepend is set.
detach Removes this node from its parent; does nothing when it has none.
empty Removes all of this node’s children, last first, as Obsidian does.
indexOf Gets the position of a node among this node’s children.
insertAfter Inserts a node into this node right after a reference child, or as the first child when there is no reference child.
instanceOf Cross-window instanceof check for DOM nodes. The mock has a single window, so it is a plain instanceof.
setChildrenInPlace Replaces this node’s children with the given nodes, in order. A node that is already a child in the right place stays attached; only the unwanted children are removed and only the misplaced nodes are inserted, as Obsidian does.