mirror of
https://github.com/DioxusLabs/dioxus
synced 2025-02-17 06:08:26 +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.
|
// create the new children afresh.
|
||||||
if shared_keys.is_empty() {
|
if shared_keys.is_empty() {
|
||||||
if !old.is_empty() {
|
if !old.is_empty() {
|
||||||
self.remove_nodes(to, &old[1..], None);
|
let m = self.create_children(to, new, parent);
|
||||||
old[0].replace(new, parent, self, to);
|
self.remove_nodes(to, old, Some(m));
|
||||||
} else {
|
} else {
|
||||||
// I think this is wrong - why are we appending?
|
// I think this is wrong - why are we appending?
|
||||||
// only valid of the if there are no trailing elements
|
// only valid of the if there are no trailing elements
|
||||||
|
|
|
@ -297,8 +297,11 @@ impl VNode {
|
||||||
dom.reclaim(id)
|
dom.reclaim(id)
|
||||||
}
|
}
|
||||||
Fragment(nodes) => {
|
Fragment(nodes) => {
|
||||||
for node in nodes {
|
for node in &nodes[..nodes.len() - 1] {
|
||||||
node.remove_node(dom, to, replace_with, gen_muts)
|
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!(
|
assert_eq!(
|
||||||
dom.render_immediate_to_vec().santize().edits,
|
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(3) },
|
||||||
Remove { id: ElementId(2) },
|
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 }
|
ReplaceWith { id: ElementId(1), m: 3 }
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Reference in a new issue