mirror of
https://github.com/DioxusLabs/dioxus
synced 2024-11-11 15:07:08 +00:00
Merge pull request #331 from Demonthos/diff-fix
fix: diff_lazynodes bug adding children
This commit is contained in:
commit
09d193d999
2 changed files with 26 additions and 0 deletions
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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 },
|
||||
]
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue