Repository: DioxusLabs/dioxus
File: packages/core/src/diff/node.rs (Rust)

Code before:
        replace_with: Option<usize>,
    ) {
        let roots = self.template.roots;
        for (idx, node) in roots.iter().enumerate() {
            let last_node = idx == roots.len() - 1;
            if let Some(id) = node.dynamic_id() {
                let dynamic_node = &self.dynamic_nodes[id];
                self.remove_dynamic_node(
                    mount,
                    dom,
                    to.as_deref_mut(),
                    destroy_component_state,
                    id,
                    dynamic_node,
                    replace_with.filter(|_| last_node),
                );
            } else if let Some(to) = to.as_deref_mut() {
                let id = dom.get_mounted_root_node(mount, idx);
                if let (true, Some(replace_with)) = (last_node, replace_with) {
                    to.replace_node_with(id, replace_with);
                } else {
                    to.remove_node(id);
                }
                dom.reclaim(id);
            }
        }
    }

    fn remove_nested_dyn_nodes<M: WriteMutations>(
        &self,
        mount: MountId,
        dom: &mut VirtualDom,
        destroy_component_state: bool,
    ) {
        let template = self.template;
        for (idx, dyn_node) in self.dynamic_nodes.iter().enumerate() {
            let path_len = template.node_paths.get(idx).map(|path| path.len());
            // Roots are cleaned up automatically above and nodes with a empty path are placeholders
            if let Some(2..) = path_len {
                self.remove_dynamic_node(
                    mount,
                    dom,
                    Option::<&mut M>::None,
                    destroy_component_state,
                    idx,
                    dyn_node,
                    None,
                )
            }
        }
    }

Review comment (suggestion):
Reclaiming the root mounted node here when mutations is None seems odd. If this is a suspended node, that id should never have been set [here](https://github.com/DioxusLabs/dioxus/blob/797e7492a1b9e188627ab7530a66607ba19376d6/packages/core/src/diff/node.rs#L607-L609)

Code after:
        replace_with: Option<usize>,
    ) {
        let roots = self.template.roots;
        for (idx, node) in roots.iter().enumerate() {
            let last_node = idx == roots.len() - 1;
            if let Some(id) = node.dynamic_id() {
                let dynamic_node = &self.dynamic_nodes[id];
                self.remove_dynamic_node(
                    mount,
                    dom,
                    to.as_deref_mut(),
                    destroy_component_state,
                    id,
                    dynamic_node,
                    replace_with.filter(|_| last_node),
                );
            } else if let Some(to) = to.as_deref_mut() {
                let id = dom.get_mounted_root_node(mount, idx);
                if let (true, Some(replace_with)) = (last_node, replace_with) {
                    to.replace_node_with(id, replace_with);
                } else {
                    to.remove_node(id);
                }
                dom.reclaim(id);
            } else {
                let id = dom.get_mounted_root_node(mount, idx);
                dom.reclaim(id);
            }
        }
    }

    fn remove_nested_dyn_nodes<M: WriteMutations>(
        &self,
        mount: MountId,
        dom: &mut VirtualDom,
        destroy_component_state: bool,
    ) {
        let template = self.template;
        for (idx, dyn_node) in self.dynamic_nodes.iter().enumerate() {
            let path_len = template.node_paths.get(idx).map(|path| path.len());
            // Roots are cleaned up automatically above and nodes with a empty path are placeholders
            if let Some(2..) = path_len {
                self.remove_dynamic_node(
                    mount,
                    dom,
                    Option::<&mut M>::None,
                    destroy_component_state,
                    idx,
                    dyn_node,
                    None,
                )