mirror of
https://github.com/DioxusLabs/dioxus
synced 2024-11-23 12:43:08 +00:00
Remove a Node listeners when it is removed (#576)
This commit is contained in:
parent
daeffd4149
commit
e98f46bbcc
1 changed files with 6 additions and 0 deletions
|
@ -641,6 +641,9 @@ impl<S: State> RealDom<S> {
|
|||
fn remove(&mut self, id: GlobalNodeId) -> Option<TemplateRefOrNode<S>> {
|
||||
// We do not need to remove the node from the parent's children list for children.
|
||||
fn inner<S: State>(dom: &mut RealDom<S>, id: GlobalNodeId) -> Option<TemplateRefOrNode<S>> {
|
||||
for nodes_listeners in dom.nodes_listening.values_mut() {
|
||||
nodes_listeners.remove(&id);
|
||||
}
|
||||
let mut either = match id {
|
||||
GlobalNodeId::VNodeId(id) => *dom.nodes[id.0].take()?,
|
||||
GlobalNodeId::TemplateId {
|
||||
|
@ -683,6 +686,9 @@ impl<S: State> RealDom<S> {
|
|||
}
|
||||
}
|
||||
};
|
||||
for nodes_listeners in self.nodes_listening.values_mut() {
|
||||
nodes_listeners.remove(&id);
|
||||
}
|
||||
if let Some(parent) = node.parent() {
|
||||
let parent = &mut self[parent];
|
||||
parent.remove_child(id);
|
||||
|
|
Loading…
Reference in a new issue