Skip to content

Commit 04b3711

Browse files
if xmlns attribute is specified, use that namespace (#3629)
Co-authored-by: JasonCG <> Co-authored-by: Matt Yan <[email protected]>
1 parent cada026 commit 04b3711

File tree

1 file changed

+12
-2
lines changed
  • packages/yew/src/dom_bundle/btag

1 file changed

+12
-2
lines changed

packages/yew/src/dom_bundle/btag/mod.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,18 @@ impl Reconcilable for VTag {
238238
impl VTag {
239239
fn create_element(&self, parent: &Element) -> Element {
240240
let tag = self.tag();
241-
242-
if tag == "svg" || parent.namespace_uri().is_some_and(|ns| ns == SVG_NAMESPACE) {
241+
// check for an xmlns attribute. If it exists, create an element with the specified
242+
// namespace
243+
if let Some(xmlns) = self
244+
.attributes
245+
.iter()
246+
.find(|(k, _)| *k == "xmlns")
247+
.map(|(_, v)| v)
248+
{
249+
document()
250+
.create_element_ns(Some(xmlns), tag)
251+
.expect("can't create namespaced element for vtag")
252+
} else if tag == "svg" || parent.namespace_uri().is_some_and(|ns| ns == SVG_NAMESPACE) {
243253
let namespace = Some(SVG_NAMESPACE);
244254
document()
245255
.create_element_ns(namespace, tag)

0 commit comments

Comments
 (0)