Skip to content

Commit

Permalink
More node removal robustness fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
nicoburns committed Oct 9, 2024
1 parent 4e3ad45 commit dd14f93
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions packages/dioxus-blitz/src/documents/dioxus_document.rs
Original file line number Diff line number Diff line change
Expand Up @@ -613,8 +613,10 @@ impl WriteMutations for MutationWriter<'_> {
// If there is an existing node already mapped to that ID and
// it has no parent, then drop it
if let Some(node_id) = self.state.try_element_to_node_id(id) {
if self.doc.get_node(node_id).unwrap().parent.is_none() {
self.doc.remove_and_drop_node(node_id);
if let Some(node) = self.doc.get_node(node_id) {
if node.parent.is_none() {
self.doc.remove_and_drop_node(node_id);
}
}
}

Expand Down Expand Up @@ -665,7 +667,7 @@ impl WriteMutations for MutationWriter<'_> {
let anchor_node_id = self.state.element_to_node_id(id);
self.maybe_push_parent_style_node(anchor_node_id);
self.doc.insert_before(anchor_node_id, &new_nodes);
self.doc.remove_and_drop_node(anchor_node_id);
self.doc.remove_node(anchor_node_id);
}

fn replace_placeholder_with_nodes(&mut self, path: &'static [u8], m: usize) {
Expand All @@ -676,7 +678,7 @@ impl WriteMutations for MutationWriter<'_> {
let anchor_node_id = self.load_child(path);
self.maybe_push_parent_style_node(anchor_node_id);
self.doc.insert_before(anchor_node_id, &new_nodes);
self.doc.remove_and_drop_node(anchor_node_id);
self.doc.remove_node(anchor_node_id);
}

fn insert_nodes_after(&mut self, id: ElementId, m: usize) {
Expand Down

0 comments on commit dd14f93

Please sign in to comment.