mirror of
https://github.com/DioxusLabs/dioxus
synced 2024-11-10 14:44:12 +00:00
drop scopes in order when dropping the virtual dom
This commit is contained in:
parent
94c0c2e5b9
commit
c172914b21
2 changed files with 7 additions and 3 deletions
|
@ -64,7 +64,7 @@ impl VirtualDom {
|
|||
self.elements.try_remove(el.0).map(|_| ())
|
||||
}
|
||||
|
||||
// Drop a scope and all its children
|
||||
// Drop a scope without dropping its children
|
||||
//
|
||||
// Note: This will not remove any ids from the arena
|
||||
pub(crate) fn drop_scope(&mut self, id: ScopeId) {
|
||||
|
|
|
@ -762,7 +762,11 @@ impl VirtualDom {
|
|||
|
||||
impl Drop for VirtualDom {
|
||||
fn drop(&mut self) {
|
||||
// Simply drop this scope which drops all of its children
|
||||
self.drop_scope(ScopeId::ROOT);
|
||||
// Drop all scopes in order of height
|
||||
let mut scopes = self.scopes.drain().collect::<Vec<_>>();
|
||||
scopes.sort_by_key(|scope| scope.context().height);
|
||||
for scope in scopes.into_iter().rev() {
|
||||
drop(scope);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue