if xmlns attribute is specified, use that namespace (#3629)

Co-authored-by: JasonCG <>
Co-authored-by: Matt Yan <syan4@ualberta.ca>
This commit is contained in:
JasonCG 2025-03-13 07:49:00 -04:00 committed by GitHub
parent cada02620a
commit 04b3711cfb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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)