mirror of
https://github.com/DioxusLabs/dioxus
synced 2024-11-10 14:44:12 +00:00
fix replacing fragments
This commit is contained in:
parent
85c7c22619
commit
b53ba7b5c7
3 changed files with 10 additions and 7 deletions
|
@ -284,8 +284,8 @@ impl VirtualDom {
|
|||
// create the new children afresh.
|
||||
if shared_keys.is_empty() {
|
||||
if !old.is_empty() {
|
||||
self.remove_nodes(to, &old[1..], None);
|
||||
old[0].replace(new, parent, self, to);
|
||||
let m = self.create_children(to, new, parent);
|
||||
self.remove_nodes(to, old, Some(m));
|
||||
} else {
|
||||
// I think this is wrong - why are we appending?
|
||||
// only valid of the if there are no trailing elements
|
||||
|
|
|
@ -297,8 +297,11 @@ impl VNode {
|
|||
dom.reclaim(id)
|
||||
}
|
||||
Fragment(nodes) => {
|
||||
for node in nodes {
|
||||
node.remove_node(dom, to, replace_with, gen_muts)
|
||||
for node in &nodes[..nodes.len() - 1] {
|
||||
node.remove_node(dom, to, None, gen_muts)
|
||||
}
|
||||
if let Some(last_node) = nodes.last() {
|
||||
last_node.remove_node(dom, to, replace_with, gen_muts)
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -347,11 +347,11 @@ fn no_common_keys() {
|
|||
assert_eq!(
|
||||
dom.render_immediate_to_vec().santize().edits,
|
||||
[
|
||||
LoadTemplate { name: "template", index: 0, id: ElementId(4) },
|
||||
LoadTemplate { name: "template", index: 0, id: ElementId(5) },
|
||||
LoadTemplate { name: "template", index: 0, id: ElementId(6) },
|
||||
Remove { id: ElementId(3) },
|
||||
Remove { id: ElementId(2) },
|
||||
LoadTemplate { name: "template", index: 0, id: ElementId(2) },
|
||||
LoadTemplate { name: "template", index: 0, id: ElementId(3) },
|
||||
LoadTemplate { name: "template", index: 0, id: ElementId(4) },
|
||||
ReplaceWith { id: ElementId(1), m: 3 }
|
||||
]
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue