zino_dioxus/extension/
vnode.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
use dioxus_core::{DynamicNode::Component, VNode};

/// Extension trait for `VNode`.
pub trait VNodeExt {
    /// Returns `true` if `self` has a given component node as its child.
    fn has_component(&self, name: &str) -> bool;
}

impl VNodeExt for VNode {
    fn has_component(&self, name: &str) -> bool {
        self.dynamic_nodes.iter().any(|node| {
            if let Component(node) = node {
                node.name == name
            } else {
                false
            }
        })
    }
}