fix placeholder template names

This commit is contained in:
Evan Almloff 2024-01-15 10:15:55 -06:00
parent 0f01f3fd84
commit a1c68448a7
3 changed files with 17 additions and 12 deletions

View file

@ -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(|_| ())

View file

@ -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]);

View file

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