Skip to content

Instantly share code, notes, and snippets.

@alexzuza
Created April 1, 2018 14:31
Show Gist options
  • Save alexzuza/36093f9e8c4c2c27c6b61634d9cd22ef to your computer and use it in GitHub Desktop.
Save alexzuza/36093f9e8c4c2c27c6b61634d9cd22ef to your computer and use it in GitHub Desktop.
IDOM
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