From 4d0af10b8d71c8624a357127acf6f77218b59781 Mon Sep 17 00:00:00 2001 From: "Davide P. Cervone" Date: Mon, 25 Jan 2016 12:02:24 -0500 Subject: [PATCH] If measurements can't be taken in getHDW(), move the test elements to the document.body instead in hopes that it is visible. Resolves issue #1353. --- unpacked/jax/output/CommonHTML/jax.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/unpacked/jax/output/CommonHTML/jax.js b/unpacked/jax/output/CommonHTML/jax.js index 793579479..580611e28 100644 --- a/unpacked/jax/output/CommonHTML/jax.js +++ b/unpacked/jax/output/CommonHTML/jax.js @@ -858,10 +858,17 @@ var test2 = CHTML.addElement(CHTML.CHTMLnode,"mjx-chartest",{className:name},[["mjx-char",{style:styles},[c,["mjx-box"]]]]); test1.firstChild.style.fontSize = test2.firstChild.style.fontSize = ""; var em = 5*CHTML.em; - var d = (test2.offsetHeight-1000)/em; - var w = test1.offsetWidth/em, h = test1.offsetHeight/em - d; + var H1 = test1.offsetHeight, H2 = test2.offsetHeight, W = test1.offsetWidth; CHTML.CHTMLnode.removeChild(test1); CHTML.CHTMLnode.removeChild(test2); + if (H2 === 0) { + em = 5*CHTML.defaultEm; + var test = document.body.appendChild(document.createElement("div")); + test.appendChild(test1); test.appendChild(test2); + H1 = test1.offsetHeight, H2 = test2.offsetHeight, W = test1.offsetWidth; + document.body.removeChild(test); + } + var d = (H2-1000)/em, w = W/em, h = H1/em - d; return {h:h, d:d, w:w} },