/// Check if the dom contains a node and its children.
Check if the dom contains a node and its children.
Check if the dom contains a node and its children .
pub fn contains_node(&self, node: &VNode) -> bool {
        match node {
            VNode::Component(_) => {
                todo!()
            }
            VNode::Element(e) => {
                if let Some(id) = e.id.get() {
                    let dom_node = &self[id];
                    match &dom_node.node_type {
                        NodeType::Element {
                            tag,
                            namespace,
                            children,
                        } => {
                            tag == e.tag
                                && namespace == &e.namespace
                                && children.iter().copied().collect::<FxHashSet<_>>()
                                    == e.children
                                        .iter()
                                        .map(|c| c.mounted_id())
                                        .collect::<FxHashSet<_>>()
                                && e.children.iter().all(|c| {
                                    self.contains_node(c)
                                        && self[c.mounted_id()].parent == e.id.get()
                                })
                        }
                        _ => false,
                    }
                } else {
                    true
                }
            }
            VNode::Fragment(f) => f.children.iter().all(|c| self.contains_node(c)),
            VNode::Placeholder(_) => true,
            VNode::Text(t) => {
                if let Some(id) = t.id.get() {
                    let dom_node = &self[id];
                    match &dom_node.node_type {
                        NodeType::Text { text } => t.text == text,
                        _ => false,
                    }
                } else {
                    true
                }
            }
        }
    }
pub fn contains_node ( & self , node : & VNode ) -> bool { match node { VNode :: Component ( _ ) => { todo ! ( ) } VNode :: Element ( e ) => { if let Some ( id ) = e . id . get ( ) { let dom_node = & self [ id ] ; match & dom_node . node_type { NodeType :: Element { tag , namespace , children , } => { tag == e . tag && namespace == & e . namespace && children . iter ( ) . copied ( ) . collect :: < FxHashSet < _ > > ( ) == e . children . iter ( ) . map ( | c | c . mounted_id ( ) ) . collect :: < FxHashSet < _ > > ( ) && e . children . iter ( ) . all ( | c | { self . contains_node ( c ) && self [ c . mounted_id ( ) ] . parent == e . id . get ( ) } ) } _ => false , } } else { true } } VNode :: Fragment ( f ) => f . children . iter ( ) . all ( | c | self . contains_node ( c ) ) , VNode :: Placeholder ( _ ) => true , VNode :: Text ( t ) => { if let Some ( id ) = t . id . get ( ) { let dom_node = & self [ id ] ; match & dom_node . node_type { NodeType :: Text { text } => t . text == text , _ => false , } } else { true } } } }
Check if the dom contains a node and its children.
Check if the dom contains a node and its children .
&self
node
&VNode