Elementals.js

Latest Version: 3.7 Final 20 December 2018

Method _.Node.walk

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:
_.Node.walk(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 _.Node.prev, _.Node.next, _.Node.first, or _.Node.last in the elementals codebase.