Class Node

Create a new tree node and set its value and optionally user data.

Constructor

class Node([value][, data])
Arguments:
  • value (String) – The node value.
  • data (object) – User data for this tree node. You may store a reference to the corresponding object in the underlying document structure. E.g. a reference to a DOM element.

Methods

append

Node#append(child)
Arguments:
  • child (object) – The new child node.

Append the given node as a child node.

forEach

Node#forEach(callback[, T])
Arguments:
  • callback (function) – The function which will be invoked for each node.
  • T (object) – Context object bound to “this” when the callback is invoked.

Invokes a callback for the node and all its child nodes in preorder (document order).

forEachDescendant

Node#forEachDescendant(callback[, T])
Arguments:
  • callback (function) – The function which will be invoked for each node.
  • T (object) – Context object bound to “this” when the callback is invoked.

Equal to forEach except that the callback is not invoked for the context node.

forEachPostorder

Node#forEachPostorder(callback[, T])
Arguments:
  • callback (function) – The function which will be invoked for each node.
  • T (object) – Context object bound to “this” when the callback is invoked.

Invokes a callback for the node and all its child nodes in postorder.

Table Of Contents

Previous topic

Tree Utilities

Next topic

Class Anchor