dom-utils

Namespaces

elementDataStore

Members

(static) elementDataStore

Source:
See:

Methods

(static) closestAncestorUntil(element, filterSelector, endSelectoropt) → {Node}

Source:

Gets closest ancestor that match selector until the end selector.

Parameters:
Name Type Attributes Default Description
element Node

Target element.

filterSelector string *

A CSS selector.

endSelector string <optional>

A CSS selector indicating where to stop. It will include this element if matched by the filter.

Returns:

Closest ancestor.

Type
Node

(static) empty(element) → {undefined}

Source:

Removes all children elements.

Parameters:
Name Type Description
element Node

Target element.

Returns:
Type
undefined

(static) getAncestors(element, filterSelectoropt, endSelectoropt) → {Array.<Node>}

Source:

Gets ancestors that match selector in DOM order.

Parameters:
Name Type Attributes Default Description
element Node

Target element.

filterSelector string <optional>
*

A CSS selector.

endSelector string <optional>

A CSS selector indicating where to stop. It will include this element if matched by the filter.

Returns:

Array of ancestors.

Type
Array.<Node>

(static) getSiblingElements(element, selectoropt) → {Array.<Node>}

Source:

Gets siblings that match selector in DOM order.

Parameters:
Name Type Attributes Description
element Node

Target element.

selector string <optional>

A CSS selector.

Returns:

Array of sibling nodes.

Type
Array.<Node>

(static) getSiblingElementsAndSelf(element, selectoropt) → {Array.<Node>}

Source:

Gets siblings that match selector and self in DOM order.

Parameters:
Name Type Attributes Description
element Node

Target element.

selector string <optional>

A CSS selector for siblings (not for self).

Returns:

Array of sibling nodes plus target element.

Type
Array.<Node>

(inner) _getSiblingElements(element, selectoropt, includeSelfopt) → {Array.<Node>}

Source:

Gets siblings that match selector in DOM order.

Parameters:
Name Type Attributes Default Description
element Node

Target element.

selector string <optional>
*

A CSS selector.

includeSelf boolean <optional>
false

Whether to include self.

Returns:

Array of sibling nodes.

Type
Array.<Node>

(inner) getChild(element, selector) → {Node}

Source:

Gets first child element, that (optionally) matches a selector.

Parameters:
Name Type Default Description
element Node

Target element.

selector string *

A CSS selector.

Returns:
  • First child element.
Type
Node

(inner) getChildren(element, selector) → {Array.<Node>}

Source:

Gets child elements, that (optionally) match a selector.

Parameters:
Name Type Default Description
element Node

Target element.

selector string *

A CSS selector.

Returns:

Array of child elements.

Type
Array.<Node>

(inner) getRepeatIndex(node) → {number}

Source:

Obtains the index of a repeat instance within its own series.

Parameters:
Name Type Description
node Element

XML node

Returns:

index

Type
number

(inner) getSiblingElement(element, selectoropt) → {Node}

Source:

Returns first sibling element (in DOM order) that optionally matches the provided selector.

Parameters:
Name Type Attributes Default Description
element Node

Target element.

selector string <optional>
*

A CSS selector.

Returns:

First sibling element in DOM order

Type
Node

(inner) getXPath(node, rootNodeNameopt, includePositionopt) → {string}

Source:

Creates an XPath from a node

Parameters:
Name Type Attributes Default Description
node Element

XML node

rootNodeName string <optional>
#document

Defaults to #document

includePosition boolean <optional>
false

Whether or not to include the positions /path/to/repeat[2]/node

Returns:

XPath

Type
string

(inner) hasPreviousCommentSiblingWithContent(node, content) → {boolean}

Source:
Parameters:
Name Type Description
node Element

Target node

content string

Text content to look for

Returns:

Whether previous comment sibling has given text content

Type
boolean

(inner) hasPreviousSiblingElementSameName(el) → {boolean}

Source:
Parameters:
Name Type Description
el Element

Target node

Returns:

Whether previous sibling has same node name

Type
boolean