Namespace

stat_dom

stat_dom

Methods

static getNodeText(node) → {string}

Retrieve text within node.
Take node.textContent for common cases (so including all children), or node.value for INPUT.
Remove HTML comments, trim the result and replace tabs & line feeds & carriage returns by spaces.

Parameters:
Name Type Description
node object

DOM node

Text of node

string

static getSelectorNode(selector, parentNodeopt) → {object}

Retrieve the first node corresponding to given selector.

Parameters:
Name Type Attributes Description
selector string

Nodes selector (id or @id or tagName:class[index] or jsnodes:code or css:selector or jquery:selector or [child index]) that can be chained (parent/child/grandchild...).

parentNode object <optional>

parent node, document if not specified. Ignored when selector is an id.

First selected node (parent node if selector is empty)

object

static getSelectorNodes(selector, parentNodeopt, firstOnlyopt, leafFilteropt) → {Array.<object>}

Provide an array of nodes corresponding to given selector.

Parameters:
Name Type Attributes Description
selector string

Nodes selector (id or @id or tagName:class[index] or jsnodes:code or css:selector or jquery:selector or [child index]) that can be chained (parent/child/grandchild...).

parentNode object <optional>

parent node, document if not specified. Ignored when selector is an id.

firstOnly boolean <optional>

Limit the search to first node found (performance improvement)

leafFilter string <optional>

css Selector to filter the leaf (performance improvement). Not use when [index] specified.

List of selected nodes (parent node if selector is empty)

Array.<object>

static getSelectorParentNode(selector, node) → {object}

Retrieve the first node in parent tree corresponding to given selector

Parameters:
Name Type Description
selector string

Nodes selector (id or @id or tagName:class[index] or jsnodes:code or css:selector or jquery:selector or [child index]) that can be chained (parent/child/grandchild...).

node object

Current node

First parent node matching selector

object

static getSelectorText(selector, parentNodeopt, evtopt) → {string}

Retrieve text of the first node corresponding to given selector

Parameters:
Name Type Attributes Description
selector string

Nodes selector (id or @id or tagName:class[index] or jsnodes:code or css:selector or jquery:selector or [child index]) that can be chained (parent/child/grandchild...).

parentNode object <optional>

parent node, document if not specified. Ignored when selector is an id.

evt object <optional>

Current event (forwarded to jsfunc:).

Text of first selected node (or parent node text when selector is empty))

string

static gnt()

Shortcut for stat_dom.getNodeText

static gsn()

Shortcut for stat_dom.getSelectorNode

static gsns()

Shortcut for stat_dom.getSelectorNodes

static gst()

Shortcut for stat_dom.getSelectorText

static inc()

Shortcut for stat_dom.isNodeClass

static isNodeClass(node, cn) → {boolean}

Check if a node contains a given class. Call node.classList.contains when available, scan className otherwise.

Parameters:
Name Type Description
node object

DOM node

cn string

class name expected

true if class is in the class list of the node

boolean