Show:
new DOMTraverser()
Class for helping us traverse the DOM.
Class for helping us traverse the DOM.
This class currently does a pre-order depth-first traversal. See DOMPostOrder for post-order traversal.
- Source:
Methods
addHandler(nodeName, action)
Add a handler to the DOM traverser.
Add a handler to the DOM traverser.
Parameters:
Name | Type | Description |
---|---|---|
nodeName |
string | |
action |
traverserHandler | A callback, called on each node we traverse that matches nodeName. |
- Source:
traverse(workNode, env, options, atTopLevel, tplInfo) → {Node|null
|true
}
Traverse the DOM and fire the handlers that are registered.
Traverse the DOM and fire the handlers that are registered.
Handlers can return
- the next node to process
- aborts processing for current node, continues with returned node
- can also be
null
, so returningworkNode.nextSibling
works even when workNode is a last child of its parent
true
- continue regular processing on current node.
Parameters:
Name | Type | Description |
---|---|---|
workNode |
Node | |
env |
MWParserEnvironment | |
options |
Object | |
atTopLevel |
boolean | |
tplInfo |
Object | Template information. |
- Source:
Returns:
- Type
-
Node
|
null
|true