Skip to content

Commit a9d8123

Browse files
committed
Address review comments. #557
1 parent aad3a6e commit a9d8123

File tree

1 file changed

+10
-16
lines changed

1 file changed

+10
-16
lines changed

unpacked/extensions/mml2jax.js

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,12 @@ MathJax.Extension.mml2jax = {
5353
//
5454
// Handle all math tags with no namespaces
5555
//
56-
this.AppendMathElements(mathArray,element.getElementsByTagName("math"));
56+
mathArray.push.apply(mathArray,element.getElementsByTagName("math"));
5757
//
5858
// Handle math with namespaces in XHTML
5959
//
6060
if (element.getElementsByTagNameNS)
61-
{this.AppendMathElements(mathArray,element.getElementsByTagNameNS(this.MMLnamespace,"math"))}
61+
{mathArray.push.apply(mathArray,element.getElementsByTagNameNS(this.MMLnamespace,"math"))}
6262
//
6363
// Handle math with namespaces in HTML
6464
//
@@ -71,7 +71,7 @@ MathJax.Extension.mml2jax = {
7171
for (i = 0, m = document.namespaces.length; i < m; i++) {
7272
var ns = document.namespaces[i];
7373
if (ns.urn === this.MMLnamespace)
74-
{this.AppendMathElements(mathArray,element.getElementsByTagName(ns.name+":math"))}
74+
{mathArray.push.apply(mathArray,element.getElementsByTagName(ns.name+":math"))}
7575
}
7676
} catch (err) {}
7777
} else {
@@ -83,36 +83,30 @@ MathJax.Extension.mml2jax = {
8383
for (i = 0, m = html.attributes.length; i < m; i++) {
8484
var attr = html.attributes[i];
8585
if (attr.nodeName.substr(0,6) === "xmlns:" && attr.nodeValue === this.MMLnamespace)
86-
{this.AppendMathElements(mathArray,element.getElementsByTagName(attr.nodeName.substr(6)+":math"))}
86+
{mathArray.push.apply(mathArray,element.getElementsByTagName(attr.nodeName.substr(6)+":math"))}
8787
}
8888
}
8989
}
9090
this.ProcessMathArray(mathArray);
9191
},
9292

93-
AppendMathElements: function(mathArray, math) {
94-
if (math.length) {
95-
for (var i = math.length-1; i >= 0; i--) {mathArray.push(math[i])}
96-
}
97-
},
98-
9993
ProcessMathArray: function (math) {
100-
var i;
101-
if (math.length) {
94+
var i, m = math.length;
95+
if (m) {
10296
if (this.MathTagBug) {
103-
for (i = math.length-1; i >= 0; i--) {
97+
for (i = 0; i < m; i++) {
10498
if (math[i].nodeName === "MATH") {this.ProcessMathFlattened(math[i])}
10599
else {this.ProcessMath(math[i])}
106100
}
107101
} else {
108-
for (i = math.length-1; i >= 0; i--) {this.ProcessMath(math[i])}
102+
for (i = 0; i < m; i++) {this.ProcessMath(math[i])}
109103
}
110104
}
111105
},
112106

113107
ProcessMath: function (math) {
114108
var parent = math.parentNode;
115-
if (!parent || parent.className === "MathJax_Preview") return;
109+
if (!parent || parent.className === MathJax.Hub.config.preRemoveClass) return;
116110
var script = document.createElement("script");
117111
script.type = "math/mml";
118112
parent.insertBefore(script,math);
@@ -132,7 +126,7 @@ MathJax.Extension.mml2jax = {
132126

133127
ProcessMathFlattened: function (math) {
134128
var parent = math.parentNode;
135-
if (!parent || parent.className === "MathJax_Preview") return;
129+
if (!parent || parent.className === MathJax.Hub.config.preRemoveClass) return;
136130
var script = document.createElement("script");
137131
script.type = "math/mml";
138132
parent.insertBefore(script,math);

0 commit comments

Comments
 (0)