fix replacing VNodes

This commit is contained in:
Evan Almloff committed 2024-01-15 10:05:04 -06:00
1 parent a8172b0ab5
commit 0f01f3fd84
1 file changed
+7 -6
+7 -6
View File
@@ -39,6 +39,11 @@ impl VNode {
}
}
// If the templates are different by name, we need to replace the entire template
if self.templates_are_different(new) {
return self.light_diff_templates(new, dom, to);
}
// Copy over the mount information
let mount_id = self.mount.get();
new.mount.set(mount_id);
@@ -53,11 +58,6 @@ impl VNode {
return;
}
// If the templates are different by name, we need to replace the entire template
if self.templates_are_different(new) {
return self.light_diff_templates(new, dom, to);
}
// If the templates are the same, we can diff the attributes and children
// Start with the attributes
self.diff_attributes(new, dom, to);
@@ -553,8 +553,8 @@ impl VNode {
.map(|(i, path)| ((i, i), path))
.peekable(),
);
// If this is a debug build, we need to check that the paths are in the correct order because hot reloading can cause scrambled states
// If this is a debug build, we need to check that the paths are in the correct order because hot reloading can cause scrambled states
#[cfg(debug_assertions)]
let (attrs_sorted, nodes_sorted) =
{ (sort_bfs(template.attr_paths), sort_bfs(template.node_paths)) };
@@ -754,6 +754,7 @@ impl VNode {
loop {
for attr in &*self.dynamic_attrs[attr_id] {
self.write_attribute(path, attr, id, mount, dom, to);
dom.mounts[mount.0].mounted_attributes[attr_id] = id;
}
// Only push the dynamic attributes forward if they match the current path (same element)