Skip to content

Instantly share code, notes, and snippets.

Created October 29, 2017 04:28
Show Gist options
  • Save anonymous/082caa01aef5b8d2aa0c7f2fa8110efb to your computer and use it in GitHub Desktop.
Save anonymous/082caa01aef5b8d2aa0c7f2fa8110efb to your computer and use it in GitHub Desktop.
// copy current children except a certain child while keeping all refs - a pain in the ass.
let i = oldParent.childNodes.length - 1
for (; i >= 0; i -= 1) {
const c = oldParent.childNodes[i]
// whatever, your condition here
if (c.nodeName.toLowerCase() !== "slot") {
newParent.appendChild(c)
}
}
// use var instead of let and const for <ES6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment