diff --git a/src/jsxy.mjs b/src/jsxy.mjs
index 2f539a3..bce75e9 100644
--- a/src/jsxy.mjs
+++ b/src/jsxy.mjs
@@ -167,8 +167,8 @@ function renderChildren(parentNode, vnodes, component, ns) {
for (let k in oldHooks) {
if (!(k in newHooks)) for (let h of oldHooks[k]) h.unmount?.();
}
- for (let n = parentNode.childNodes.length - vnodes.length; n > 0; n--) {
- unmount(parentNode.lastChild).remove();
+ for (let i = nodes.length-1; i >= vnodes.length; i--) {
+ unmount(nodes[i]).remove()
}
}
diff --git a/test/fixtures/jsxy.mjs.json b/test/fixtures/jsxy.mjs.json
index a472cdb..67b9169 100644
--- a/test/fixtures/jsxy.mjs.json
+++ b/test/fixtures/jsxy.mjs.json
@@ -248,5 +248,7 @@
"jsxy: render: render root/app from any child (1)": "
1
",
"jsxy: render: renderChildren works correctly when removing children (0)": "
123
",
"jsxy: render: renderChildren works correctly when removing children (1)": "
13
",
+ "jsxy: render: renderChildren works correctly when removing multiple children (0)": "
123
",
+ "jsxy: render: renderChildren works correctly when removing multiple children (1)": "