Handle missing elements better (see issue 486)

This commit is contained in:
Davide P. Cervone 2015-08-20 10:32:21 -04:00
parent 6b399e3726
commit 948620fa02
2 changed files with 5 additions and 3 deletions

View File

@ -488,7 +488,7 @@ MathJax.Hub.Register.StartupHook("CommonHTML Jax Ready",function () {
var h = state.HH, d = state.DD;
for (var i = 0, m = LABELS.length; i < m; i++) {
if (!state.HD) {h = H[i]; d = D[i]}
if (LABELS[i]) {
if (LABELS[i] && this.data[i].data[0]) {
labels.appendChild(LABELS[i]);
var lbox = this.data[i].data[0].CHTML;
T += h - lbox.h;

View File

@ -2050,6 +2050,7 @@
W = Math.max(W,scale*(bbox[i].w + (bbox[i].L||0) + (bbox[i].R||0)));
}
}
if (!bbox[this.base]) bbox[this.base] = CHTML.BBOX.empty();
return W;
},
//
@ -2208,7 +2209,8 @@
//
var boxes = [], BBOX = CHTML.BBOX.empty(this.CHTML);
for (var i = 0, m = this.data.length; i < m; i++) boxes[i] = this.CHTMLbboxFor(i);
var bbox = boxes[this.base], sbox = boxes[this.sub], Sbox = boxes[this.sup];
var bbox = boxes[this.base] || CHTML.BBOX.empty(),
sbox = boxes[this.sub], Sbox = boxes[this.sup];
var sscale = (sub ? sbox.rscale : 1), Sscale = (sup ? Sbox.rscale : 1);
BBOX.combine(bbox,0,0);
//
@ -2369,7 +2371,7 @@
node = this.CHTMLdefaultNode(node,{
childNodes:["mjx-box","mjx-root"], forceChild:true, noBBox:true
});
var base = node.firstChild;
var base = node.firstChild || HTML.Element("mjx-box");
var sqrt = HTML.addElement(node,"mjx-box"); sqrt.appendChild(base);
var bbox = this.CHTMLbboxFor(0), BBOX = CHTML.BBOX.empty(this.CHTML);
var t = CHTML.TEX.rule_thickness, T = CHTML.TEX.surd_height, p = t, q, H;