From 3183eca200344322cd77c236d3aee2948d92ad7e Mon Sep 17 00:00:00 2001 From: "Davide P. Cervone" Date: Sun, 20 Mar 2016 11:48:12 -0400 Subject: [PATCH] Add checks to make sure that the math hasn't been removed from the page. (Resolves issue #1384.) --- unpacked/MathJax.js | 4 ++-- unpacked/extensions/fast-preview.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/unpacked/MathJax.js b/unpacked/MathJax.js index 117752453..2b4c1dc11 100644 --- a/unpacked/MathJax.js +++ b/unpacked/MathJax.js @@ -2182,7 +2182,7 @@ MathJax.Hub = { // // Check if already processed or needs processing // - if (!script.MathJax || script.MathJax.state === STATE.PROCESSED) {state.i++; continue}; + if (!script.parentNode || !script.MathJax || script.MathJax.state === STATE.PROCESSED) {state.i++; continue}; if (!script.MathJax.elementJax || script.MathJax.state === STATE.UPDATE) { this.checkScriptSiblings(script); // remove preJax/postJax etc. var type = script.type.replace(/ *;(.|\s)*/,""); // the input jax type @@ -2286,7 +2286,7 @@ MathJax.Hub = { // Check that there is an element jax // script = state.scripts[state.i]; - if (!script || !script.MathJax || script.MathJax.error) {state.i++; continue} + if (!script || !script.parentNode || !script.MathJax || script.MathJax.error) {state.i++; continue} var jax = script.MathJax.elementJax; if (!jax) {state.i++; continue} // // Call the output Jax's Process method (which will be its Translate() diff --git a/unpacked/extensions/fast-preview.js b/unpacked/extensions/fast-preview.js index 73f3ee43f..bc55d2a4b 100644 --- a/unpacked/extensions/fast-preview.js +++ b/unpacked/extensions/fast-preview.js @@ -100,7 +100,7 @@ // and call the PreviewHTML output jax to create the preview // Preview: function (data) { - if (!this.Active()) return; + if (!this.Active() || !data.script.parentNode) return; var preview = data.script.MathJax.preview || data.script.previousSibling; if (!preview || preview.className !== MathJax.Hub.config.preRemoveClass) { preview = HTML.Element("span",{className:MathJax.Hub.config.preRemoveClass});