Skip to content

Instantly share code, notes, and snippets.

@snewcomer
Created April 2, 2019 01:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save snewcomer/517d90a1c322899e318d525977973490 to your computer and use it in GitHub Desktop.
Save snewcomer/517d90a1c322899e318d525977973490 to your computer and use it in GitHub Desktop.
Tree Walker
function indexTree(root) {
var treeWalker = document.createTreeWalker(
root,
NodeFilter.SHOW_ELEMENT);
var el;
while((el = treeWalker.nextNode())) {
var key = getNodeKey(el);
if (key) {
fromNodesLookup[key] = el;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment