Skip to content
Cheton Wu edited this page Nov 28, 2016 · 4 revisions

Index


contains(node)

Returns a boolean value indicating whether a node is a descendant of a given node or not.

Arguments
  1. node (Object): Specifies the node that may be contained by (a descendant of) a specified node.
Returns

(boolean): Returns true if a node is a descendant of a specified node, otherwise false. A descendant can be a child, grandchild, great-grandchild, and so on.

Example
rootNode.contains(node);
// → true
node.contains(rootNode);
// → false

getChildAt(index)

Gets a child node at the specified index.

Arguments
  1. index (number): The index of the child node.
Returns

(Object): Returns a Node object of the specified child, null otherwise.

Example
node.getChildAt(-1);
// → null
node.getChildAt(0);
// → Node {}

getChildren()

Gets the child nodes.

Returns

(Array): Returns an array of Node objects containing the child nodes.

Example
node.getChildren();
// → [Node {}, Node {}]

getFirstChild()

Gets the first child node.

Returns

(Object): Returns a Node object of the first child, null otherwise.

Example
node.getFirstChild();
// → Node {}

getLastChild()

Gets the last child node.

Returns

(Object): Returns a Node object of the last child, null otherwise.

Example
node.getLastChild();
// → Node {}

getNextSibling()

Gets the next sibling node.

Returns

(Object): Returns a Node object of the next sibling, null otherwise.

Example
node.getNextSibling();
// → Node {}

getParent()

Gets the parent node.

Returns

(Object): Returns a Node object of the parent, null otherwise.

Example
node.getParent();
// → Node {}

getPreviousSibling()

Gets the previous sibling node.

Returns

(Object): Returns a Node object of the previous sibling, null otherwise.

Example
node.getPreviousSibling();
// → Node {}

hasChildren()

Checks whether this node has children.

Returns

(boolean): Returns true if the node has children, false otherwise.

Example
node.hasChildren();
// → true

isLastChild()

Checks whether this node is the last child of its parent.

Returns

(boolean): Returns true if the node is the last child of its parent, false otherwise.

Example
node.isLastChild();
// → true