mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Math
synced 2024-11-23 23:25:02 +00:00
Push math nodes onto mathArray individually to avoid problem in IE < 9 where push.apply doesn't work on a nodeList. Also, avoid duplicate elements in the array by checking for namespace prefixes. This needs to work for both HTML and XHTML. Resolves issue #672.
Signed-off-by: physikerwelt <wiki@physikerwelt.de>
Change-Id: I0e2071aebee4e524960b01c4a5a10e49b5520846
(cherry picked from commit d463f88c18
)
This commit is contained in:
parent
c7a8073501
commit
01ca982894
24
modules/MathJax/unpacked/extensions/mml2jax.js
vendored
24
modules/MathJax/unpacked/extensions/mml2jax.js
vendored
|
@ -53,12 +53,11 @@ MathJax.Extension.mml2jax = {
|
|||
//
|
||||
// Handle all math tags with no namespaces
|
||||
//
|
||||
mathArray.push.apply(mathArray,element.getElementsByTagName("math"));
|
||||
this.PushMathElements(mathArray,element,"math");
|
||||
//
|
||||
// Handle math with namespaces in XHTML
|
||||
//
|
||||
if (element.getElementsByTagNameNS)
|
||||
{mathArray.push.apply(mathArray,element.getElementsByTagNameNS(this.MMLnamespace,"math"))}
|
||||
this.PushMathElements(mathArray,element,"math",this.MMLnamespace);
|
||||
//
|
||||
// Handle math with namespaces in HTML
|
||||
//
|
||||
|
@ -71,7 +70,7 @@ MathJax.Extension.mml2jax = {
|
|||
for (i = 0, m = document.namespaces.length; i < m; i++) {
|
||||
var ns = document.namespaces[i];
|
||||
if (ns.urn === this.MMLnamespace)
|
||||
{mathArray.push.apply(mathArray,element.getElementsByTagName(ns.name+":math"))}
|
||||
{this.PushMathElements(mathArray,element,ns.name+":math")}
|
||||
}
|
||||
} catch (err) {}
|
||||
} else {
|
||||
|
@ -83,13 +82,28 @@ MathJax.Extension.mml2jax = {
|
|||
for (i = 0, m = html.attributes.length; i < m; i++) {
|
||||
var attr = html.attributes[i];
|
||||
if (attr.nodeName.substr(0,6) === "xmlns:" && attr.nodeValue === this.MMLnamespace)
|
||||
{mathArray.push.apply(mathArray,element.getElementsByTagName(attr.nodeName.substr(6)+":math"))}
|
||||
{this.PushMathElements(mathArray,element,attr.nodeName.substr(6)+":math")}
|
||||
}
|
||||
}
|
||||
}
|
||||
this.ProcessMathArray(mathArray);
|
||||
},
|
||||
|
||||
PushMathElements: function (array,element,name,namespace) {
|
||||
var math, preview = MathJax.Hub.config.preRemoveClass;
|
||||
if (namespace) {
|
||||
if (!element.getElementsByTagNameNS) return;
|
||||
math = element.getElementsByTagNameNS(namespace,name);
|
||||
} else {
|
||||
math = element.getElementsByTagName(name);
|
||||
}
|
||||
for (var i = 0, m = math.length; i < m; i++) {
|
||||
var parent = math[i].parentNode;
|
||||
if (parent && parent.className !== preview && !math[i].prefix === !namespace)
|
||||
{array.push(math[i])}
|
||||
}
|
||||
},
|
||||
|
||||
ProcessMathArray: function (math) {
|
||||
var i, m = math.length;
|
||||
if (m) {
|
||||
|
|
Loading…
Reference in a new issue