more bugfixes

This commit is contained in:
Evan Almloff 2022-12-22 15:09:58 -06:00
parent 776c5e8839
commit 21ca1599eb
2 changed files with 16 additions and 5 deletions

View file

@ -255,7 +255,9 @@ impl<'b> VirtualDom {
root: ElementId,
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);
loop {

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
#[cfg(debug_assertions)]
if let Some(template) = self.templates.get(right_template.template.get().name) {
let prev_template = right_template.template.get();
if *template != prev_template {
if *template != right_template.template.get() {
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;
for (idx, attr) in node.dynamic_attrs.iter().enumerate() {
// 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;
}