Fix svg foreignObject that contains DIVs (#6755)

* xmlns attribute defined in element takes precedence

* use predefined tagNamespaces variable as default value

* change code as suggested by Jeremy
This commit is contained in:
Mario Pietsch 2022-07-05 18:46:31 +02:00 committed by GitHub
parent a59ec3ebf7
commit 76bc2f7524
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 2 deletions

View File

@ -42,16 +42,22 @@ ElementWidget.prototype.render = function(parent,nextSibling) {
this.tag = "h" + headingLevel;
}
// Select the namespace for the tag
var XHTML_NAMESPACE = "http://www.w3.org/1999/xhtml";
var tagNamespaces = {
svg: "http://www.w3.org/2000/svg",
math: "http://www.w3.org/1998/Math/MathML",
body: "http://www.w3.org/1999/xhtml"
body: XHTML_NAMESPACE
};
this.namespace = tagNamespaces[this.tag];
if(this.namespace) {
this.setVariable("namespace",this.namespace);
} else {
this.namespace = this.getVariable("namespace",{defaultValue: "http://www.w3.org/1999/xhtml"});
if (this.hasAttribute("xmlns")) {
this.namespace = this.getAttribute("xmlns");
this.setVariable("namespace",this.namespace);
} else {
this.namespace = this.getVariable("namespace",{defaultValue: XHTML_NAMESPACE});
}
}
// Invoke the th-rendering-element hook
var parseTreeNodes = $tw.hooks.invokeHook("th-rendering-element",null,this);