Created
April 1, 2018 14:27
-
-
Save alexzuza/7846e2761bc555be72bce213db6c7b9b to your computer and use it in GitHub Desktop.
IDOM
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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