Utils.traverse
A module containing rich document tree traversal methods.
These methods are “filter” methods, meaning they will return an
array-like object of results
from each callback invocation. A result of true
will collect
the object passed; a truthy result will collect the value returned;
a falsey result will not be collected. An example follows.
function handler( obj ) { var result = false; if (obj && obj.id === "unique") { // criterion met result = true; } return result; }
Utils.traverse.linear
Method that traverses an array-like object, calling a callback on each item.
Return value: Array
Utils.traverse.nodes
Method that traverses a node-like object's child nodes and calls a callback with the current node passed.
Return value: Array
Utils.traverse.elements
Method that traverses a node-like object's “children” and calls a callback with the current node passed.
Return value: Array
Utils.traverse.nodeTree
Method that traverses a node-like object's subtree, calling a callback on each node-like object in the array-like object.
[]
);
Return value: Array
Utils.traverse.recursive
Method that recursively traverses an array-like object, calling a callback on each item.
[]
);
Return value: Array
Utils.traverse.elementTree
Method that traverses a node-like object's subtree, calling a callback on each element node-like object in the array-like object.
[]
);
Return value: Array
Utils.traverse.getNodes
Warning: this property will return null
if the host environment is detected to be unsuitable;
an if
block or a similar construct should
be used for detection.
Method that traverses a node-like object's child nodes and collects them in a “static” array-like object.
Return value: Array || null
Utils.traverse.getElements
Warning: this property will return null
if the host environment is detected to be unsuitable;
an if
block or a similar construct should
be used for detection.
Method that traverses a node-like object's “children” and collects them in a “static” array.
Return value: Array || null
Utils.traverse.getNodeTree
Method that recursively traverses a node-like object's subtree, collecting each node-like object in the array-like object.
Return value: Array || null
Utils.traverse.getElementTree
Method that recursively traverses a node-like object's subtree, collecting each element node-like object in the array-like object.
Return value: Array || null
Utils.traverse.clearNodes
Method that traverses a node-like object's child nodes and removes them.
Return value: Array || null
Utils.traverse.clearElements
Method that traverses a node-like object's “children” and removes them.
Return value: Array || null