aboutsummaryrefslogtreecommitdiff
path: root/src/lib/dom.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/dom.ts')
-rw-r--r--src/lib/dom.ts6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/lib/dom.ts b/src/lib/dom.ts
new file mode 100644
index 0000000..2ab4de5
--- /dev/null
+++ b/src/lib/dom.ts
@@ -0,0 +1,6 @@
+export function replaceChildren(parent: Element, ...newChildren: Element[]) {
+ while (parent.lastChild) {
+ parent.removeChild(parent.lastChild)
+ }
+ newChildren.forEach(c => parent.appendChild(c))
+}