ParentNode

ParentNode

Many Node subclasses are potentially parents of other Nodes. Those classes will derive from this instead of directly from Node, to get the ability to hold children.

Constructor

(abstract) new ParentNode()

Description:
  • Creates an instance of ParentNode.
Source:

Classes

ParentNode

Members

children :Array.<Node>

Source:
Type:

Methods

add(node) → {Node}

Description:
  • Add a child node. Side effect: sets the parent of the added node.
Source:
Parameters:
Name Type Description
node Node The node to add
Returns:
The added node
Type
Node

(generator) descendantElements() → {Generator.<Element>}

Description:
  • Iterate over all of the descendants of this node which are Elements, to infinite depth, in prefix order. That is, parents are yielded before their children.
Source:
Returns:
Type
Generator.<Element>

(generator) descendants() → {Generator.<Node>}

Description:
  • Iterate over all of the descendants of this node, to infinite depth, in prefix order. That is, parents are yielded before their children.
Source:
Returns:
Type
Generator.<Node>

(generator) elements(localopt, nsopt) → {Generator.<Element>}

Description:
  • Iterate over all of the children of this Node which are Elements and match the given local name and namespace (if specified).
Source:
Parameters:
Name Type Attributes Description
local string <optional>
The localname. If not given, match elements with any name
ns string <optional>
The namespace URI to match. If not given, match elements with any namespace.
Returns:
Type
Generator.<Element>

text(newTextopt) → {string|Node}

Description:
  • Gets the text associated with all of the child nodes, concatenated together. This sometimes has surprising results, because of included whitespace.
Source:
Parameters:
Name Type Attributes Description
newText string <optional>
New text to insert. Invalid on ParentNode but used for subclasses.
Returns:
The concatenated text
Type
string | Node

toString(optionsopt) → {string}

Description:
  • Convert the node to a string containing representations of all of the children of this node. Override this and call super as needed.
Source:
Parameters:
Name Type Attributes Description
options MaybeStylizedSeparated <optional>
How to convert to string
Returns:
The node, converted to a string
Type
string