Skip to content

Instantly share code, notes, and snippets.

@alexzuza
Created April 1, 2018 14:27
Show Gist options
  • Save alexzuza/7846e2761bc555be72bce213db6c7b9b to your computer and use it in GitHub Desktop.
Save alexzuza/7846e2761bc555be72bce213db6c7b9b to your computer and use it in GitHub Desktop.
IDOM
// The current nodes being processed
let currentNode = null;
let currentParent = null;
function enterNode() {
currentParent = currentNode;
currentNode = null;
}
function nextNode() {
currentNode = currentNode ?
currentNode.nextSibling :
currentParent.firstChild;
}
function exitNode() {
currentNode = currentParent;
currentParent = currentParent.parentNode;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment