Elementals.js

Latest Version: 2.0 RC 3 14 March 2017

Method _.nodeWalk

Handler for walking the DOM based on different Element parameters such as firstChild, lastChild, nextSibling, or previousSibling. Mostly meant for internal use, but who knows... You might find it useful.

Calling Convention:
_.nodeWalk(Element, [nodeMask || tagName], firstMethod, nextMethod )
Parameters:
Element
Target to walk the child nodes of.
nodeMask optional

A bitwise mask used to filter the results. See the Node Masking page for more information.

If omitted, a mask of 1 (matching for nodeType 1) is used.

tagName optional
A tagName to match. When used instead of a nodeMask only elements of node type 1 with a matching tagName will be counted.
firstMethod
Reference off Element to start walking from. Should be a string, typically one of:
  • 'firstChild'
  • 'lastChild'
  • 'nextSibling'
  • 'previousSibling'
nextMethod
If the first element doesn't match the mask, this method should be used to test for the next one. Typically one of:
  • 'nextSibling'
  • 'previousSibling'
Returns:
First element to match the mask, or null if no match is found.

Meant for internal use, if you want to see how it works look at _.nodePrev, _.nodeNext, _.nodeFirst, or _.nodeNext in the elementals.js codebase.