浏览代码

fix placeholder template names

Evan Almloff 1 年之前
父节点
当前提交
a1c68448a7
共有 3 个文件被更改,包括 17 次插入12 次删除
  1. 1 4
      packages/core/src/arena.rs
  2. 14 6
      packages/core/src/diff/node.rs
  3. 2 2
      packages/core/src/nodes.rs

+ 1 - 4
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(|_| ())

+ 14 - 6
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]);

+ 2 - 2
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: &[],