dom-walker
DOM Walker based on TreeWalker
Install
$ component install alexeyraspopov/dom-walker
$ bower install dom-walker
API
walk(root, process, options);
-
root
- start element -
process
- processing function-
node
- current node -
next
- iterator function (go to next node)-
direction
(optional) - which node should be next ('node'
by default).'node'
goes to next node (including nested) and'sibling'
goes to next sibling node (avoiding nested nodes)
-
-
-
options
(optional)-
acceptNode
- TreeWalker filter function. Accept all elements by default -
whatToShow
- TreeWalker option.NodeFilter.SHOW_ELEMENT
by default
-
Usage
var walk = require('dom-walker');
var root = document.getElementById('viewport');
walk(root, function(node, next){
console.log(node);
next();
});
License
MIT License (c) Alexey Raspopov