Expand all

abstract ve.BranchNode

Constructor

new ve.BranchNode(children)abstract #

Branch node mixin.

Extenders are expected to inherit from ve.Node.

Branch nodes are immutable, which is why there are no methods for adding or removing children. DataModel classes will add this functionality, and other subclasses will implement behavior that mimics changes made to DataModel nodes.

Parameters:

Name Type Description
children Array.<ve.Node>

Array of children to add

Source:
Branch node mixin.

Methods

getChildren() → {Array.<ve.Node>} #

Get child nodes.

Source:

Returns:

List of child nodes

Type
Array.<ve.Node>
Get child nodes.

getNodeFromOffset(offset, [shallow]) → {ve.Node|null} #

Get a node from an offset.

This method is pretty expensive. If you need to get different slices of the same content, get the content first, then slice it up locally.

Parameters:

Name Type Attributes Description
offset number

Offset get node for

shallow boolean optional

Do not iterate into child nodes of child nodes

Source:

Returns:

Node at offset, or null if none was found

Type
ve.Node | null

Throws:

If offset is out of bounds

Type
Error
Get a node from an offset.

hasChildren() → {boolean} #

Check if the node has children.

Source:

Returns:

Whether the node has children

Type
boolean
Check if the node has children.

indexOf(node) → {number} #

Get the index of a child node.

Parameters:

Name Type Description
node ve.dm.Node

Child node to find index of

Source:

Returns:

Index of child node or -1 if node was not found

Type
number
Get the index of a child node.

setDocument(doc) #

Set the document the node is a part of.

Parameters:

Name Type Description
doc ve.Document

Document this node is a part of

Source:
See:
Set the document the node is a part of.

setRoot(root) #

Set the root node.

Parameters:

Name Type Description
root ve.BranchNode | null

Node to use as root

Source:
See:
Set the root node.

traverse(callback) #

Traverse a branch node depth-first.

Parameters:

Name Type Description
callback function

Callback to execute for each traversed node

Properties:
Name Type Description
node ve.Node

Node being traversed

Source:
Traverse a branch node depth-first.