From 036e1ff0f53a60966de4d08b32b2400b07cba338 Mon Sep 17 00:00:00 2001 From: Evan Almloff Date: Thu, 31 Aug 2023 15:38:31 -0500 Subject: [PATCH] remove node refs before dropping nodes --- packages/core/src/arena.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/core/src/arena.rs b/packages/core/src/arena.rs index 53695d9d7..667c7123d 100644 --- a/packages/core/src/arena.rs +++ b/packages/core/src/arena.rs @@ -118,6 +118,10 @@ impl VirtualDom { } fn drop_scope_inner(&mut self, node: &VNode) { + if let Some(id) = node.parent.get() { + self.element_refs.remove(id.0); + } + node.dynamic_nodes.iter().for_each(|node| match node { DynamicNode::Component(c) => { if let Some(f) = c.scope.get() { @@ -128,7 +132,11 @@ impl VirtualDom { DynamicNode::Fragment(nodes) => { nodes.iter().for_each(|node| self.drop_scope_inner(node)) } - DynamicNode::Placeholder(_) => {} + DynamicNode::Placeholder(placeholder) => { + if let Some(id) = placeholder.parent.get() { + self.element_refs.remove(id.0); + } + } DynamicNode::Text(_) => {} }); }