Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Skip to content

Node

The base class for all node types in the game

Properties

childNodes

NodeList Read Only
Returns a live NodeList containing all the children of this node. A live NodeList automatically updates when the children of the node change, so you don't need to re-query for changes.

firstChild

Node | null Read Only
Returns the first direct child node of this node, or null if the node has no children.

lastChild

Node | null Read Only
Returns the last direct child node of this node, or null if the node has no children.

previousSibling

Node | null Read Only
Returns the previous sibling node in the tree, or null if there is no previous sibling.

nextSibling

Node | null Read Only
Returns the next sibling node in the tree, or null if there is no next sibling.

nodeName

string Read Only
Returns the name of the node (typically the tag name for elements).

parentNode

Node | null Read Only
Returns the parent node of this node, or null if this node has no parent (e.g., it's the root node or not part of a tree).

isEmpty

Returns true when this node has no child nodes (alias for !hasChildNodes()). Per Gap 4: reference games use node.isEmpty interchangeably with node.childNodes.isEmpty.

Methods

hasClass(className: string)

Checks if this node has the specified CSS class.

NameTypeDescription
classNamestringThe class name to check for
Returns

boolean - True if the node has the class, false otherwise

appendChild(node: Node | string | Selector)

Adds a node as the last child of this node. If the node is already part of the game tree, it will be moved from its current position to become the last child of this node.

NameTypeDescription
nodeNode | string | SelectorThe node to add as a child

contains(node: Node)

Checks if the specified node is a descendant of this node (i.e., a child, grandchild, etc.).

NameTypeDescription
nodeNodeThe node to check
Returns

boolean - True if the node is a descendant, false otherwise

hasChildNodes()

Checks if this node has any child nodes.

Returns

boolean - True if the node has children, false otherwise

insertBefore(node: Node | string | Selector, referenceNode: Node | string | Selector)

Inserts a node as a child of this node, positioned before the specified reference node. If no reference node is provided, the new node becomes the first child.

NameTypeDescription
nodeNode | string | SelectorThe node to insert
referenceNodeNode | string | SelectorThe reference node to insert before, or null to insert at the beginning