more bugfixes

This commit is contained in:
Evan Almloff committed 2022-12-22 15:09:58 -06:00
1 parent 776c5e8839
commit 21ca1599eb
2 files changed
+16 -5

No files matched your search

+3 -1
View File
@@ -255,7 +255,9 @@ impl<'b> VirtualDom {
root: ElementId, root: ElementId,
node: &VNode, node: &VNode,
) { ) {
while let Some((mut attr_id, path)) = attrs.next_if(|(_, p)| p[0] == root_idx) { while let Some((mut attr_id, path)) =
attrs.next_if(|(_, p)| p.first().copied() == Some(root_idx))
{
let id = self.assign_static_node_as_dynamic(path, root, node, attr_id); let id = self.assign_static_node_as_dynamic(path, root, node, attr_id);
loop { loop {
+13 -4
View File
@@ -58,10 +58,11 @@ impl<'b> VirtualDom {
// If hot reloading is enabled, we need to make sure we're using the latest template // If hot reloading is enabled, we need to make sure we're using the latest template
#[cfg(debug_assertions)] #[cfg(debug_assertions)]
if let Some(template) = self.templates.get(right_template.template.get().name) { if let Some(template) = self.templates.get(right_template.template.get().name) {
let prev_template = right_template.template.get(); if *template != right_template.template.get() {
if *template != prev_template {
right_template.template.set(*template); right_template.template.set(*template);
return self.replace(left_template, [right_template]); if *template != left_template.template.get() {
return self.replace(left_template, [right_template]);
}
} }
} }
@@ -803,7 +804,15 @@ impl<'b> VirtualDom {
let mut id = None; let mut id = None;
for (idx, attr) in node.dynamic_attrs.iter().enumerate() { for (idx, attr) in node.dynamic_attrs.iter().enumerate() {
// We'll clean up the root nodes either way, so don't worry // We'll clean up the root nodes either way, so don't worry
if node.template.get().attr_paths[idx].len() == 1 { let path_len = node
.template
.get()
.attr_paths
.get(idx)
.map(|path| path.len());
// if the path is 1 the attribute is in the root, so we don't need to clean it up
// if the path is 0, the attribute is a not attached at all, so we don't need to clean it up
if let Some(..=1) = path_len {
continue; continue;
} }