DioxusLabs/dioxus · error

` = ` is ambiguous: matching elements

Error message

`{attr_name}={attr_value}` is ambiguous: {} matching elements

What it means

element_id_by_attr found multiple live elements sharing the same attribute name/value pair. Since a unique ElementId is required to fire synthetic events, the ambiguity itself is the test's fault and this panic reports the match count.

Solutions

  1. The attribute selector matches multiple elements. Narrow the selector so it matches exactly one element.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at packages/oracle/src/renderer.rs:1143 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of DioxusLabs/dioxus@24f6a829df (2026-08-23). Data as JSON: /api/errors/d687fd90eec18816. Report an issue: GitHub.

Appendix: source

Thrown at packages/oracle/src/renderer.rs:1143

            [id] => *id,
            [] => panic!("no live element with tag `{tag}` found in the oracle DOM"),
            many => panic!(
                "tag `{tag}` is ambiguous: {} matching elements (use element_id_by_attr to disambiguate)",
                many.len(),
            ),
        }
    }

    /// Find the live [`ElementId`] of the unique element whose attribute
    /// `attr_name` (in the default namespace) has the value `attr_value`.
    /// Panics if zero or more than one element matches.
    pub fn element_id_by_attr(&self, attr_name: &str, attr_value: &str) -> ElementId {
        let mut hits = Vec::new();
        self.collect_element_ids_by_attr(self.arena.root, attr_name, attr_value, &mut hits);
        match hits.as_slice() {
            [id] => *id,
            [] => panic!("no live element with `{attr_name}={attr_value}` found in the oracle DOM"),
            many => panic!(
                "`{attr_name}={attr_value}` is ambiguous: {} matching elements",
                many.len(),
            ),
        }
    }

    fn collect_element_ids_by_tag(&self, node: NodeId, tag: &str, out: &mut Vec<ElementId>) {
        let n = self.arena.node(node);
        if let NodeKind::Element { tag: t, .. } = &n.kind {
            if t == tag {
                if let Some(id) = self.element_id_for_node(node) {
                    out.push(id);
                }
            }
        }
        for &child in &n.children {
            self.collect_element_ids_by_tag(child, tag, out);
        }

View on GitHub (pinned to 24f6a829df)