Created
June 18, 2017 21:18
-
-
Save keyserfaty/bcb3143eacd734992059d3866fa140a9 to your computer and use it in GitHub Desktop.
A function to render/remove a node from tree
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
export const renderNode = (render, node, parent) => { | |
const _node = d.querySelector(`[data-unique-id='${node.getAttribute('data-unique-id')}']`) | |
if (_node == null && render) { | |
const _parent = d.querySelector(parent) | |
_parent.appendChild(node) | |
} else if (_node != null && !render) { | |
_node.parentNode.removeChild(_node) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment