For AI agents: a documentation index is available at /llms.txt. Markdown versions of all pages are available by appending .md to any URL.
Interface TreeWalker
currentNode: Node;
filter: NodeFilter | null;
root: Node;
whatToShow: number;
firstChild(): Node | null;
lastChild(): Node | null;
nextNode(): Node | null;
nextSibling(): Node | null;
parentNode(): Node | null;
previousNode(): Node | null;
previousSibling(): Node | null;
}
Properties
currentNode
The TreeWalker.currentNode property represents the Node which the TreeWalker is currently pointing at.
Readonlyfilter
The TreeWalker.filter read-only property returns the NodeFilter associated with the TreeWalker.
Readonlyroot
The TreeWalker.root read-only property returns the root Node that the TreeWalker traverses.
ReadonlywhatToShow
The TreeWalker.whatToShow read-only property returns a bitmask that indicates the types of nodes to show. Non-matching nodes are skipped, but their children may be included, if relevant.
Methods
firstChild
-
The
TreeWalker.firstChild()method moves the current Node to the first visible child of the current node, and returns the found child. If no such child exists, it returns null and the current node is not changed.Returns Node | null
lastChild
-
The
TreeWalker.lastChild()method moves the current Node to the last visible child of the current node, and returns the found child. If no such child exists, it returns null and the current node is not changed.Returns Node | null
nextNode
-
The
TreeWalker.nextNode()method moves the current Node to the next visible node in the document order, and returns the found node. If no such node exists, it returns null and the current node is not changed.Returns Node | null
nextSibling
-
The
TreeWalker.nextSibling()method moves the current Node to its next sibling, if any, and returns the found sibling. If there is no such node, it returns null and the current node is not changed.Returns Node | null
parentNode
-
The
TreeWalker.parentNode()method moves the current Node to the first visible ancestor node in the document order, and returns the found node. If no such node exists, or if it is above the TreeWalker's root node, it returns null and the current node is not changed.Returns Node | null
previousNode
-
The
TreeWalker.previousNode()method moves the current Node to the previous visible node in the document order, and returns the found node. If no such node exists, or if it is before that the root node defined at the object construction, it returns null and the current node is not changed.Returns Node | null
previousSibling
-
The
TreeWalker.previousSibling()method moves the current Node to its previous sibling, if any, and returns the found sibling. If there is no such node, it returns null and the current node is not changed.Returns Node | null
The
TreeWalkerobject represents the nodes of a document subtree and a position within them.MDN Reference