mirror of
https://github.com/yewstack/yew.git
synced 2025-12-08 21:26:25 +00:00
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:
parent
cada02620a
commit
04b3711cfb
@ -238,8 +238,18 @@ impl Reconcilable for VTag {
|
|||||||
impl VTag {
|
impl VTag {
|
||||||
fn create_element(&self, parent: &Element) -> Element {
|
fn create_element(&self, parent: &Element) -> Element {
|
||||||
let tag = self.tag();
|
let tag = self.tag();
|
||||||
|
// check for an xmlns attribute. If it exists, create an element with the specified
|
||||||
if tag == "svg" || parent.namespace_uri().is_some_and(|ns| ns == SVG_NAMESPACE) {
|
// 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);
|
let namespace = Some(SVG_NAMESPACE);
|
||||||
document()
|
document()
|
||||||
.create_element_ns(namespace, tag)
|
.create_element_ns(namespace, tag)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user