Skip to content

Commit

Permalink
Fix render cycle cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
edoardocavazza committed May 30, 2024
1 parent 7ec2006 commit d63ed8e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/lovely-toys-reflect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@chialab/dna": patch
---

Fix render cycle cleanup.
6 changes: 5 additions & 1 deletion src/render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,11 @@ export const internalRender = (
}

while (currentIndex <= --end) {
context.node.removeChild(contextChildren.splice(end, 1)[0].node);
const [child] = contextChildren.splice(end, 1);
const parentNode = child.node.parentNode;
if (parentNode === context.node || (realm?.open && parentNode === realm.node && realm.root === context.node)) {
context.node.removeChild(child.node);
}
}

return contextChildren;
Expand Down

0 comments on commit d63ed8e

Please sign in to comment.