Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save benjamingwynn/d73277e7db6fb7e0afa5d219a13982c2 to your computer and use it in GitHub Desktop.
Save benjamingwynn/d73277e7db6fb7e0afa5d219a13982c2 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