Created
April 1, 2018 14:31
-
-
Save alexzuza/36093f9e8c4c2c27c6b61634d9cd22ef 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
function renderDOM(name) { | |
const node = name === '#text' ? | |
document.createTextNode('') : | |
document.createElement(name); | |
currentParent.insertBefore(node, currentNode); | |
currentNode = node; | |
return node; | |
} | |
function elementOpen(name) { | |
nextNode(); | |
const node = renderDOM(name); | |
enterNode(); | |
return currentParent; | |
} | |
function elementClose(node) { | |
exitNode(); | |
return currentNode; | |
} | |
function text(value) { | |
nextNode(); | |
const node = renderDOM('#text'); | |
node.data = value; | |
return currentNode; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment