Merge pull request #331 from Demonthos/diff-fix

fix: diff_lazynodes bug adding children
This commit is contained in:
Jon Kelley authored and GitHub committed 2022-04-04 12:15:31 -04:00
commit 09d193d999
2 files changed
+26

No files matched your search

+1
View File
@@ -423,6 +423,7 @@ impl<'b> DiffState<'b> {
match (old.children.len(), new.children.len()) {
(0, 0) => {}
(0, _) => {
self.mutations.push_root(root);
let created = self.create_children(new.children);
self.mutations.append_children(created as u32);
}
+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,
[
PushRoot { root: 1 },
CreateElement { root: 2, tag: "div" },
AppendChildren { many: 1 },
]
);
}