# [Math Processing Error] with scripts and href in HTML-CSS output #364

Closed
opened this issue Dec 19, 2012 · 9 comments

Projects
None yet
2 participants
Contributor

### fred-wang commented Dec 19, 2012

 The following code generates a Math Processing Error  $MathJax x$  The important parts seem to be the script element (you can try with munderover, msub etc) and the href (you can change the mtext by another element). The error is the following: boxes[i].bbox is undefined file http://cdn.mathjax.org/mathjax/latest/unpacked/jax/output/HTML-CSS/jax.js line 2450
Contributor Author

### fred-wang commented Dec 24, 2012

 I proposed a fix on my issue364 branch: https://github.com/fred-wang/MathJax/compare/master...issue364 When there is a href attribute, HTMLcreateSpan creates a new "a" element before creating the span. At the end it sets the bbox on the parent "a" too but still returns the span child. I made it return the "a" element intead and that seems to make the test case work.

### ghost assigned fred-wangDec 24, 2012

Contributor Author

### fred-wang commented Jan 5, 2013

 Crashtests/issue364.html => In testsuite
Member

### dpvc commented Feb 12, 2013

 I think the solution is actually in a different part of the code. The HTMLcreateSpan() has to return the inner span. In this case is that this.boxes[i] is the result of HTMLCSS.createBox(), and its contents' positions are set via HTMLCSS.placeBox(); it is the latter that is supposed to set the bbox for the surrounding box. When a span is positioned in the box via placeBox, it looks for the span's parentNode and uses its bbox as the one for the surrounding box. When the span has an href, however, the parent node is the a not the span for the box. So I suggest that placeBox is the right place to fix this error, by adding something like if (parent.nodeName === "a") {parent = parent.parentNode}  or perhaps while (parent && !parent.isBox) {parent = parent.parentNode}  so that you "bubble up" to the actual result of the createBox() call.
Contributor Author

### fred-wang commented Feb 13, 2013

 I don't think that it will work, at least not on the testcase I give. Using the debugger, I see that the items of boxes already have isBox = true before the call to HTMLCSS.MeasureSpans ; after this call only the one without href has new HH and bbox properties ; then the boxes[i] is accessed and raise the error for the one with href ; placeBox is called later in that function.
Member

### dpvc commented Feb 13, 2013

 OK, I see. Then perhaps the parent on line 785 (in MeasureSpans) also needs to be adjusted to take account of the surrounding . Maybe it would be good to add a method to MML.mbase to do the parent node lookup so that it handles these things.
Contributor Author

### fred-wang commented Mar 20, 2013

 It seems that modifying Measured to get the innermost isBox ancestor (at the two places where span.parentNode is called) fixes the issue on the testcase too, although I'm not sure to understand why and whether it is correct (if I modify placeBox too, I get an error). I'm probably not the best person to fix that issue, as I don't really know the HTML output code. @dpvc would you mind taking care of that issue? => unassigning myself

### dpvc pushed a commit to dpvc/MathJax that referenced this issue Apr 28, 2013

 Add HTMLCSS.parentNode() that returns a span's parentNode, skipping o… 
…ver <a> tags. Resolves issue mathjax#364.
 9752fd6 
Member

### dpvc commented Apr 28, 2013

 The issue364 branch of my fork of MathJax includes a fix (it skips over the parent  element).
Contributor Author

### dpvc pushed a commit to dpvc/MathJax that referenced this issue Apr 29, 2013

 Merge branch 'issue364' into develop 
Resolves issue mathjax#364.
 62236bb 
Member

### dpvc commented Apr 29, 2013

 => Merged

Closed