fix lazynode diff bug adding children

This commit is contained in:
Evan Almloff committed 2022-03-26 12:53:24 -05:00
1 parent b228e1e4eb
commit aec5cd9dfa
2 files changed
+26

No files matched your search

+1
View File
@@ -424,6 +424,7 @@ impl<'b> DiffState<'b> {
(0, 0) => {}
(0, _) => {
let created = self.create_children(new.children);
self.mutations.push_root(root);
self.mutations.append_children(created as u32);
}
(_, _) => self.diff_children(old.children, new.children),
+25
View File
@@ -730,3 +730,28 @@ fn remove_list_nokeyed() {
]
);
}
#[test]
fn add_nested_elements() {
let vdom = new_dom();
let (_create, change) = vdom.diff_lazynodes(
rsx! {
div{}
},
rsx! {
div{
div{}
}
},
);
assert_eq!(
change.edits,
[
CreateElement { root: 2, tag: "div" },
PushRoot { root: 1 },
AppendChildren { many: 1 },
]
);
}