Skip to main content
The Deno 2 Release Candidate is here
Learn more
Module

x/gauntlet/imports/happy_dom.ts>TreeWalker

Work-in-progress front-end tool which does put a smile on my face
Latest
class TreeWalker
Re-export
import { TreeWalker } from "https://deno.land/x/gauntlet@v0.0.9/imports/happy_dom.ts";

The TreeWalker object represents the nodes of a document subtree and a position within them.

Constructors

new
TreeWalker(
root: INode,
whatToShow?: number,
filter?: INodeFilter,
)

Constructor.

Properties

private
filterNode

Filters a node.

Based on solution: https://gist.github.com/shawndumas/1132009

currentNode: INode
filter: INodeFilter
root: INode
whatToShow: number

Methods

Moves the current Node to the first visible child of the current node, and returns the found child. It also moves the current node to this child. If no such child exists, returns null and the current node is not changed.

Moves the current Node to the last visible child of the current node, and returns the found child. It also moves the current node to this child. If no such child exists, null is returned and the current node is not changed.

Moves the current Node to the next visible node in the document order.

Moves the current Node to its next sibling, if any, and returns the found sibling. If there is no such node, null is returned and the current node is not changed.

Moves the current Node to the first visible ancestor node in the document order, and returns the found node. It also moves the current node to this one. If no such node exists, or if it is before that the root node defined at the object construction, returns null and the current node is not changed.

Moves the current Node to the previous visible node in the document order, and returns the found node. It also moves the current node to this one. If no such node exists, or if it is before that the root node defined at the object construction, returns null and the current node is not changed.

Moves the current Node to its previous sibling, if any, and returns the found sibling. If there is no such node, return null and the current node is not changed.