mixin Node-Traversal
Extends Node
with tree traversal utility methods.
Details:
- See:
Methods
getAncestors(selector) → {Array.<smx.Node>}
- static
Gets a list of all ancestor nodes matching the given selector, ordered from outer to inner.
Parameters
-
selector
{String}
Returns
-
{Array.<smx.Node>}
isAncestorOf(node) → {Boolean}
- static
Checks if node is an ancestor of another.
Parameters
-
node
{smx.Node}
:reference node
Returns
-
{Boolean}
isMatch(selector) → {Boolean}
- static
Checks if node matches the given selector.
Parameters
-
selector
{String}
:css selector to match
Returns
-
{Boolean}
find(selector) → {Array.<Node>}
- static
Finds all descendant nodes matching the given selector.
Parameters
-
selector
{String}
:search selector
Returns
-
{Array.<Node>}
findOne(selector) → {smx.Node}
- static
This method is like find
but returns only the first result.
Parameters
-
selector
{String}
:search selector
Returns
-
{smx.Node}
getChildren([selector]) → {Array.<Node>}
- static
Gets the children nodes matching the given selector.
Parameters
-
[selector]
{String}
Returns
-
{Array.<Node>}
getFirst([selector]) → {smx.Node}
- static
Gets the first child node matching the given selector.
Parameters
-
[selector]
{String}
Returns
-
{smx.Node}
getLast([selector]) → {smx.Node}
- static
Gets the last child node matching the given selector.
Parameters
-
[selector]
{String}
Returns
-
{smx.Node}
getChildAt(index) → {smx.Node}
- static
Gets child node at given index
Parameters
-
index
{Integer}
:index position
Returns
-
{smx.Node}
isDescendantOf(node) → {Boolean}
- static
Checks if a node is child of another
Parameters
-
node
{smx.Node}
:reference node
Returns
-
{Boolean}
getNext([selector]) → {smx.Node}
- static
Gets the next sibling node matching the given selector.
Parameters
-
[selector]
{String}
:filter selector
Returns
-
{smx.Node}
getAllNext([selector]) → {Array.<smx.Node>}
- static
Gets all next sibling nodes matching the given selector.
Parameters
-
[selector]
{String}
:filter selector
Returns
-
{Array.<smx.Node>}
getPrevious([selector]) → {smx.Node}
- static
Gets the previous sibling node matching the given selector.
Parameters
-
[selector]
{String}
:filter selector
Returns
-
{smx.Node}
getAllPrevious([selector]) → {Array.<smx.Node>}
- static
Gets all previous sibling nodes matching the given selector.
Parameters
-
[selector]
{String}
:filter selector
Returns
-
{Array.<smx.Node>}