Skip to content

Instantly share code, notes, and snippets.

@keyserfaty
Created June 18, 2017 21:18
Show Gist options
  • Save keyserfaty/bcb3143eacd734992059d3866fa140a9 to your computer and use it in GitHub Desktop.
Save keyserfaty/bcb3143eacd734992059d3866fa140a9 to your computer and use it in GitHub Desktop.
A function to render/remove a node from tree
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