Node
The base class for all node types in the game
Properties
childNodes | 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 | Read Only | |
| Returns the first direct child node of this node, or null if the node has no children. | ||
lastChild | Read Only | |
| Returns the last direct child node of this node, or null if the node has no children. | ||
previousSibling | Read Only | |
| Returns the previous sibling node in the tree, or null if there is no previous sibling. | ||
nextSibling | Read Only | |
| Returns the next sibling node in the tree, or null if there is no next sibling. | ||
nodeName | Read Only | |
| Returns the name of the node (typically the tag name for elements). | ||
parentNode | 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.
| Name | Type | Description |
|---|---|---|
| className | The class name to check for |
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.
| Name | Type | Description |
|---|---|---|
| node | The 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.).
| Name | Type | Description |
|---|---|---|
| node | The node to check |
hasChildNodes()
Checks if this node has any child nodes.
ReturnsinsertBefore(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.
| Name | Type | Description |
|---|---|---|
| node | The node to insert | |
| referenceNode | The reference node to insert before, or null to insert at the beginning |

