From 04b3711cfbee3da31fa899eaa4daf2f3a56f1509 Mon Sep 17 00:00:00 2001 From: JasonCG Date: Thu, 13 Mar 2025 07:49:00 -0400 Subject: [PATCH] if xmlns attribute is specified, use that namespace (#3629) Co-authored-by: JasonCG <> Co-authored-by: Matt Yan --- packages/yew/src/dom_bundle/btag/mod.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/packages/yew/src/dom_bundle/btag/mod.rs b/packages/yew/src/dom_bundle/btag/mod.rs index 4ebb40238..0c2a2710a 100644 --- a/packages/yew/src/dom_bundle/btag/mod.rs +++ b/packages/yew/src/dom_bundle/btag/mod.rs @@ -238,8 +238,18 @@ impl Reconcilable for VTag { impl VTag { fn create_element(&self, parent: &Element) -> Element { let tag = self.tag(); - - if tag == "svg" || parent.namespace_uri().is_some_and(|ns| ns == SVG_NAMESPACE) { + // check for an xmlns attribute. If it exists, create an element with the specified + // namespace + if let Some(xmlns) = self + .attributes + .iter() + .find(|(k, _)| *k == "xmlns") + .map(|(_, v)| v) + { + document() + .create_element_ns(Some(xmlns), tag) + .expect("can't create namespaced element for vtag") + } else if tag == "svg" || parent.namespace_uri().is_some_and(|ns| ns == SVG_NAMESPACE) { let namespace = Some(SVG_NAMESPACE); document() .create_element_ns(namespace, tag)