fix changing the order of dynamic nodes
This commit is contained in:
1 parent
db7a1ec0b0
commit
04a923f83e
3 files changed
+159
-49
No files matched your search
+26
-20
@@ -61,6 +61,7 @@ impl<'b> VirtualDom {
|
||||
let prev_template = right_template.template.get();
|
||||
if *template != prev_template {
|
||||
right_template.template.set(*template);
|
||||
return self.replace(left_template, [right_template]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -820,12 +821,17 @@ impl<'b> VirtualDom {
|
||||
|
||||
fn remove_nested_dyn_nodes(&mut self, node: &VNode) {
|
||||
for (idx, dyn_node) in node.dynamic_nodes.iter().enumerate() {
|
||||
// Roots are cleaned up automatically above
|
||||
if node.template.get().node_paths[idx].len() == 1 {
|
||||
continue;
|
||||
let path_len = node
|
||||
.template
|
||||
.get()
|
||||
.node_paths
|
||||
.get(idx)
|
||||
.map(|path| path.len());
|
||||
match path_len {
|
||||
Some(2..) => self.remove_dynamic_node(dyn_node, false),
|
||||
// Roots are cleaned up automatically above and nodes with a empty path are placeholders
|
||||
_ => continue,
|
||||
}
|
||||
|
||||
self.remove_dynamic_node(dyn_node, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -859,25 +865,25 @@ impl<'b> VirtualDom {
|
||||
}
|
||||
|
||||
fn remove_component_node(&mut self, comp: &VComponent, gen_muts: bool) {
|
||||
let scope = comp.scope.take().unwrap();
|
||||
if let Some(scope) = comp.scope.take() {
|
||||
match unsafe { self.scopes[scope.0].root_node().extend_lifetime_ref() } {
|
||||
RenderReturn::Sync(Some(t)) => self.remove_node(t, gen_muts),
|
||||
_ => todo!("cannot handle nonstandard nodes"),
|
||||
};
|
||||
|
||||
match unsafe { self.scopes[scope.0].root_node().extend_lifetime_ref() } {
|
||||
RenderReturn::Sync(Some(t)) => self.remove_node(t, gen_muts),
|
||||
_ => todo!("cannot handle nonstandard nodes"),
|
||||
};
|
||||
let props = self.scopes[scope.0].props.take();
|
||||
|
||||
let props = self.scopes[scope.0].props.take();
|
||||
self.dirty_scopes.remove(&DirtyScope {
|
||||
height: self.scopes[scope.0].height,
|
||||
id: scope,
|
||||
});
|
||||
|
||||
self.dirty_scopes.remove(&DirtyScope {
|
||||
height: self.scopes[scope.0].height,
|
||||
id: scope,
|
||||
});
|
||||
*comp.props.borrow_mut() = unsafe { std::mem::transmute(props) };
|
||||
|
||||
*comp.props.borrow_mut() = unsafe { std::mem::transmute(props) };
|
||||
|
||||
// make sure to wipe any of its props and listeners
|
||||
self.ensure_drop_safety(scope);
|
||||
self.scopes.remove(scope.0);
|
||||
// make sure to wipe any of its props and listeners
|
||||
self.ensure_drop_safety(scope);
|
||||
self.scopes.remove(scope.0);
|
||||
}
|
||||
}
|
||||
|
||||
fn find_first_element(&self, node: &'b VNode<'b>) -> ElementId {
|
||||
|
||||
Reference in new issue
Block a user