From ae8ae0cb72923285b5dd07cf8ab5b334296639bb Mon Sep 17 00:00:00 2001 From: "Davide P. Cervone" <dpvc@union.edu> Date: Wed, 23 Dec 2015 19:40:41 -0500 Subject: [PATCH] Fix a number of issues found by running IE8. --- unpacked/MathJax.js | 2 +- .../jax/output/CommonHTML/autoload/maction.js | 2 +- .../jax/output/CommonHTML/autoload/menclose.js | 5 +++++ .../jax/output/CommonHTML/autoload/mtable.js | 4 ++-- .../output/CommonHTML/autoload/multiline.js | 1 + unpacked/jax/output/CommonHTML/jax.js | 18 +++++++++--------- 6 files changed, 19 insertions(+), 13 deletions(-) diff --git a/unpacked/MathJax.js b/unpacked/MathJax.js index a3cf94759..c81c3ab02 100644 --- a/unpacked/MathJax.js +++ b/unpacked/MathJax.js @@ -1042,7 +1042,7 @@ MathJax.HTML = { Element: function (type,def,contents) { var obj = document.createElement(type), id; if (def) { - if (def.style) { + if (def.hasOwnProperty("style")) { var style = def.style; def.style = {}; for (id in style) {if (style.hasOwnProperty(id)) {def.style[id.replace(/-([a-z])/g,this.ucMatch)] = style[id]}} diff --git a/unpacked/jax/output/CommonHTML/autoload/maction.js b/unpacked/jax/output/CommonHTML/autoload/maction.js index 756dddb4d..74a6cb135 100644 --- a/unpacked/jax/output/CommonHTML/autoload/maction.js +++ b/unpacked/jax/output/CommonHTML/autoload/maction.js @@ -148,7 +148,7 @@ MathJax.Hub.Register.StartupHook("CommonHTML Jax Ready",function () { // tip.style.filter = CHTML.config.styles["#MathJax_CHTML_Tooltip"].filter; if (this === currentTip) return; tip.style.left = x+"px"; tip.style.top = y+"px"; - tip.innerHTML = '<mjx-chtml><mjx-math></mjx-math></mjx-chtml>'; + tip.innerHTML = '<span class="mjx-chtml"><span class="mjx-math"></span></span>'; CHTML.getMetrics(jax); try {this.data[1].toCommonHTML(tip.firstChild.firstChild)} catch(err) { if (!err.restart) throw err; diff --git a/unpacked/jax/output/CommonHTML/autoload/menclose.js b/unpacked/jax/output/CommonHTML/autoload/menclose.js index 7e5258444..f375a72ad 100644 --- a/unpacked/jax/output/CommonHTML/autoload/menclose.js +++ b/unpacked/jax/output/CommonHTML/autoload/menclose.js @@ -306,6 +306,11 @@ MathJax.Hub.Register.StartupHook("CommonHTML Jax Ready",function () { } }); + // + // Just use default toCommonHTML for EI8 + // + if (!document.createElementNS) delete MML.menclose.prototype.toCommonHTML; + MathJax.Hub.Startup.signal.Post("CommonHTML menclose Ready"); MathJax.Ajax.loadComplete(CHTML.autoloadDir+"/menclose.js"); }); diff --git a/unpacked/jax/output/CommonHTML/autoload/mtable.js b/unpacked/jax/output/CommonHTML/autoload/mtable.js index 0f4716326..a6f4f750c 100644 --- a/unpacked/jax/output/CommonHTML/autoload/mtable.js +++ b/unpacked/jax/output/CommonHTML/autoload/mtable.js @@ -506,7 +506,7 @@ MathJax.Hub.Register.StartupHook("CommonHTML Jax Ready",function () { // Propagate full-width equations, and reserve room for equation plus label // node.style.width = this.CHTML.pwidth = "100%"; - node.style.minWidth = this.CHTML.mwidth = CHTML.Em(tw); + node.style.minWidth = this.CHTML.mwidth = CHTML.Em(Math.max(0,tw)); } }); @@ -549,7 +549,7 @@ MathJax.Hub.Register.StartupHook("CommonHTML Jax Ready",function () { var row = []; options.rows.push(row); var label = CHTML.Element("mjx-label"); options.labels.push(label); this.CHTMLaddChild(label,0,options); - options.labeled = true; + if (this.data[0]) options.labeled = true; // // Add the cells to the row // diff --git a/unpacked/jax/output/CommonHTML/autoload/multiline.js b/unpacked/jax/output/CommonHTML/autoload/multiline.js index 507ebb732..e85b43cf9 100644 --- a/unpacked/jax/output/CommonHTML/autoload/multiline.js +++ b/unpacked/jax/output/CommonHTML/autoload/multiline.js @@ -121,6 +121,7 @@ MathJax.Hub.Register.StartupHook("CommonHTML Jax Ready",function () { this.CHTMLaddLine(stack,start,[],state,ENDVALUES,broken); node.style.width = stack.style.width = this.CHTML.pwidth = "100%"; + this.CHTML.mwidth = CHTML.Em(this.CHTML.w); this.CHTML.isMultiline = parent.CHTML.isMultiline = true; stack.style.verticalAlign = CHTML.Em(state.d - this.CHTML.d); diff --git a/unpacked/jax/output/CommonHTML/jax.js b/unpacked/jax/output/CommonHTML/jax.js index 44bdce4a7..793579479 100644 --- a/unpacked/jax/output/CommonHTML/jax.js +++ b/unpacked/jax/output/CommonHTML/jax.js @@ -828,7 +828,7 @@ var c = this.unicodeChar(n); var HDW = this.getHDW(c,unknown.className); // ### FIXME: provide a means of setting the height and depth for individual characters - unknown[n] = [.8,.2,HDW.w,0,HDW.w,{a:(HDW.h-HDW.d)/2, h:HDW.h, d:HDW.d}]; + unknown[n] = [.8,.2,HDW.w,0,HDW.w,{a:Math.max(0,(HDW.h-HDW.d)/2), h:HDW.h, d:HDW.d}]; unknown[n].c = c; }, styledText: function (variant,text) { @@ -842,7 +842,7 @@ var unknown = this.STYLEDTEXT[id]; if (!unknown["_"+text]) { var HDW = this.getHDW(text,variant.className||"",style); - unknown["_"+text] = [.8,.2,HDW.w,0,HDW.w,{a:(HDW.h-HDW.d)/2, h:HDW.h, d:HDW.d}]; + unknown["_"+text] = [.8,.2,HDW.w,0,HDW.w,{a:Math.max(0,(HDW.h-HDW.d)/2), h:HDW.h, d:HDW.d}]; unknown["_"+text].c = text; } return {type:"unknown", n:"_"+text, font:unknown, style:style, rscale:variant.rscale}; @@ -1031,7 +1031,7 @@ ext.style.marginTop = CHTML.Em(-c-EFUZZ/2/k); var TEXT = ext.textContent, text = "\n"+TEXT; while (--n > 0) TEXT += text; - ext.firstChild.textContent = TEXT; + ext.textContent = TEXT; node.appendChild(ext); if (delim.mid) { node.appendChild(mid); @@ -1089,7 +1089,7 @@ right.style.marginleft = CHTML.Em(-rbox.l); var TEXT = ext.textContent, text = TEXT; while (--n > 0) TEXT += text; - ext.firstChild.textContent = TEXT; + ext.textContent = TEXT; node.appendChild(ext); if (delim.mid) { node.appendChild(mid); @@ -1516,7 +1516,7 @@ BBOX.mwidth = this.data[0].CHTML.mwidth; style.width = "100%"; } else if (BBOX.pwidth) { - BBOX.mwidth = BBOX.w; + BBOX.mwidth = CHTML.Em(BBOX.w); style.width = "100%"; } else if (BBOX.w < 0) { style.width = "0px"; @@ -1526,7 +1526,7 @@ // ### FIXME: adjust for width, height, vertical-align? for (var i = 0, m = CHTML.BBOX.styleAdjust.length; i < m; i++) { var data = CHTML.BBOX.styleAdjust[i]; - if (style[data[0]]) BBOX.adjust(style[data[0]],data[1],data[2],data[3]); + if (data && style[data[0]]) BBOX.adjust(style[data[0]],data[1],data[2],data[3]); } }, @@ -1573,7 +1573,7 @@ if (!values.weight && values.mathvariant.match(/bold/)) values.weight = "bold"; if (!values.style && values.mathvariant.match(/italic/)) values.style = "italic"; this.CHTMLvariant = {fonts:[], noRemap:true, cache:{}, style: { - "font-family":values.family, "font-weight":values.weight, "font-style":values.style + "font-family":values.family, "font-weight":values.weight||"normal", "font-style":values.style||"normal" }}; return; } @@ -1700,7 +1700,7 @@ if (!node.getAttribute("role")) node.setAttribute("role","math"); if (this.CHTML.pwidth) { node.parentNode.style.width = this.CHTML.pwidth; - node.parentNode.style.minWidth = this.CHTML.mwidth; + node.parentNode.style.minWidth = this.CHTML.mwidth||CHTML.Em(this.CHTML.w); } else if (!this.isMultiline && this.Get("display") === "block") { var values = this.getValues("indentalignfirst","indentshiftfirst","indentalign","indentshift"); if (values.indentalignfirst !== MML.INDENTALIGN.INDENTALIGN) values.indentalign = values.indentalignfirst; @@ -1984,7 +1984,7 @@ bbox.w = bbox.r = w; bbox.h = bbox.t = h; bbox.d = bbox.b = d; bbox.l = 0; if (w < 0) {node.style.marginRight = CHTML.Em(w); w = 0} node.style.width = CHTML.Em(w); - node.style.height = CHTML.Em(h+d); + node.style.height = CHTML.Em(Math.max(0,h+d)); if (d) node.style.verticalAlign = CHTML.Em(-d); this.CHTMLhandleBBox(node); this.CHTMLhandleColor(node);