From a1c68448a7b4ca0f03407776e22228a59d8282f4 Mon Sep 17 00:00:00 2001 From: Evan Almloff Date: Mon, 15 Jan 2024 10:15:55 -0600 Subject: [PATCH] fix placeholder template names --- packages/core/src/arena.rs | 5 +---- packages/core/src/diff/node.rs | 20 ++++++++++++++------ packages/core/src/nodes.rs | 4 ++-- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/packages/core/src/arena.rs b/packages/core/src/arena.rs index baabd318c..76e100006 100644 --- a/packages/core/src/arena.rs +++ b/packages/core/src/arena.rs @@ -58,10 +58,7 @@ impl VirtualDom { pub(crate) fn try_reclaim(&mut self, el: ElementId) -> Option<()> { if el.0 == 0 { - panic!( - "Cannot reclaim the root element - {:#?}", - std::backtrace::Backtrace::force_capture() - ); + panic!("Cannot reclaim the root element",); } self.elements.try_remove(el.0).map(|_| ()) diff --git a/packages/core/src/diff/node.rs b/packages/core/src/diff/node.rs index ed1e3182b..347dbe2fa 100644 --- a/packages/core/src/diff/node.rs +++ b/packages/core/src/diff/node.rs @@ -44,14 +44,9 @@ impl VNode { return self.light_diff_templates(new, dom, to); } - // Copy over the mount information let mount_id = self.mount.get(); - new.mount.set(mount_id); - let mount = &mut dom.mounts[mount_id.0]; - - // Update the reference to the node for bubbling events - mount.node = new.clone_mounted(); + self.move_mount_to(new, dom); // If the templates are the same, we don't need to do anything, except copy over the mount information if self == new { @@ -72,6 +67,17 @@ impl VNode { }); } + fn move_mount_to(&self, new: &VNode, dom: &mut VirtualDom) { + // Copy over the mount information + let mount_id = self.mount.get(); + new.mount.set(mount_id); + + let mount = &mut dom.mounts[mount_id.0]; + + // Update the reference to the node for bubbling events + mount.node = new.clone_mounted(); + } + fn diff_dynamic_node( &self, mount: MountId, @@ -481,6 +487,8 @@ impl VNode { match matching_components(self, new) { None => self.replace([new], parent, dom, to), Some(components) => { + self.move_mount_to(new, dom); + for (idx, (old_component, new_component)) in components.into_iter().enumerate() { let mount = &dom.mounts[mount_id.0]; let scope_id = ScopeId(mount.mounted_dynamic_nodes[idx]); diff --git a/packages/core/src/nodes.rs b/packages/core/src/nodes.rs index bb3bcc98c..f53db1f97 100644 --- a/packages/core/src/nodes.rs +++ b/packages/core/src/nodes.rs @@ -177,7 +177,7 @@ impl VNode { dynamic_nodes: Box::new([]), dynamic_attrs: Box::new([]), template: Cell::new(Template { - name: "dioxus-empty", + name: "packages/core/nodes.rs:180:0:0", roots: &[], node_paths: &[], attr_paths: &[], @@ -195,7 +195,7 @@ impl VNode { dynamic_nodes: Box::new([DynamicNode::Placeholder(Default::default())]), dynamic_attrs: Box::new([]), template: Cell::new(Template { - name: "dioxus-placeholder", + name: "packages/core/nodes.rs:198:0:0", roots: &[TemplateNode::Dynamic { id: 0 }], node_paths: &[&[]], attr_paths: &[],