Constructor
new TreeWalker(root, acceptNodeopt, onlyElementNodesopt, startNodeopt)
- Source:
Create a tree walker.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
root |
Node | external:Node | Node that limits where the tree walker can go within this document's tree: only the root node and its descendants. |
||
acceptNode |
function |
<optional> |
Function that returns |
|
onlyElementNodes |
boolean |
<optional> |
false
|
Walk only on element nodes, ignoring nodes of other types. |
startNode |
Node | external:Node |
<optional> |
root
|
Node to set as a current node. |
Methods
firstChild() → (nullable) {Node}
- Source:
Go to the first child node.
Returns:
- Type
- Node
lastChild() → (nullable) {Node}
- Source:
Go to the last child node.
Returns:
- Type
- Node
nextNode() → (nullable) {Node}
- Source:
Go to the next node (don't confuse with the next sibling).
Returns:
- Type
- Node
nextSibling() → (nullable) {Node}
- Source:
Go to the next sibling node.
Returns:
- Type
- Node
parentNode() → (nullable) {Node}
- Source:
Go to the parent node.
Returns:
- Type
- Node
previousNode() → (nullable) {Node}
- Source:
Go to the previous node (don't confuse with the previous sibling).
Returns:
- Type
- Node
previousSibling() → (nullable) {Node}
- Source:
Go to the previous sibling node.
Returns:
- Type
- Node
(protected) tryMove(prop) → (nullable) {Node}
- Source:
Try changing the current node to a node specified by the property.
Parameters:
Name | Type | Description |
---|---|---|
prop |
string |
Returns:
- Type
- Node