Skip to content

Commit 0e433e2

Browse files
committed
Fix getNode() yet again to walk the tree properly. Also, make CHTMLcoreNode() step through inferred rows (to match what Core() does). Finally, make CHTMLaddChild() add a box of the correct type if forceChild is set. Resolves issue mathjax#1541.
1 parent 7523687 commit 0e433e2

File tree

1 file changed

+10
-10
lines changed
  • unpacked/jax/output/CommonHTML

1 file changed

+10
-10
lines changed

unpacked/jax/output/CommonHTML/jax.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -365,14 +365,13 @@
365365
// nodes, not nodes that might be nested deeper in the tree (see issue #1447).
366366
//
367367
getNode: function (node,type) {
368-
while (node && node.childNodes.length === 1 && node.firstChild.id == null)
369-
node = node.firstChild;
370-
if (node) {
371-
var name = RegExp("\\b"+type+"\\b");
368+
var name = RegExp("\\b"+type+"\\b");
369+
while (node) {
372370
for (var i = 0, m = node.childNodes.length; i < m; i++) {
373371
var child = node.childNodes[i];
374372
if (name.test(child.className)) return child;
375373
}
374+
node = (node.firstChild && (node.firstChild.id||"") === "" ? node.firstChild : null);
376375
}
377376
return null;
378377
},
@@ -1386,12 +1385,10 @@
13861385
},
13871386
CHTMLaddChild: function (node,i,options) {
13881387
var child = this.data[i], cnode;
1388+
var type = options.childNodes;
1389+
if (type instanceof Array) type = type[i]||"span";
13891390
if (child) {
1390-
var type = options.childNodes;
1391-
if (type) {
1392-
if (type instanceof Array) type = type[i]||"span";
1393-
node = CHTML.addElement(node,type);
1394-
}
1391+
if (type) node = CHTML.addElement(node,type);
13951392
cnode = child.toCommonHTML(node,options.childOptions);
13961393
if (type && child.CHTML.rscale !== 1) {
13971394
// move scale factor to outer container (which seems to be more accurate)
@@ -1405,7 +1402,9 @@
14051402
if (cbox.skew) bbox.skew = cbox.skew;
14061403
if (cbox.pwidth) bbox.pwidth = cbox.pwidth;
14071404
}
1408-
} else if (options.forceChild) {cnode = CHTML.addElement(node,"mjx-box")}
1405+
} else if (options.forceChild) {
1406+
cnode = CHTML.addElement(node,(type||"mjx-box"));
1407+
}
14091408
return cnode;
14101409
},
14111410

@@ -1415,6 +1414,7 @@
14151414
return node;
14161415
},
14171416
CHTMLcoreNode: function (node) {
1417+
if (this.inferRow && this.data[0]) return this.data[0].CHTMLcoreNode(node.firstChild);
14181418
return this.CHTMLchildNode(node,this.CoreIndex());
14191419
},
14201420

0 commit comments

Comments
 (0)