Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MathJax crashes if rendering target removed from document context #730

Closed
ysulyma opened this issue Feb 5, 2014 · 2 comments

Comments

Projects
None yet
3 participants
@ysulyma
Copy link

commented Feb 5, 2014

I have a single-page app that uses MathJax as well as AJAX navigation. If a user navigates away from a page before MathJax has finished rendering, it will try to access a span that no longer exists in the document, resulting in an error (and breaking all subsequent JavaScript execution). The error occurs at line 589 of jax/output/HTML-CSS/jax.js.

This is kind of strange given that MathJax has no problem with e.g. processing document fragments before they are inserted into the document.

How can I tell MathJax to abort rendering of these elements?

@dpvc dpvc added Accepted labels Feb 5, 2014

@pkra pkra removed Accepted labels Feb 5, 2014

@dpvc dpvc added this to the Bugfix Version milestone Feb 6, 2014

@dpvc

This comment has been minimized.

Copy link
Member

commented Feb 6, 2014

It looks like the problem comes when MathJx looks up the math element by its ID, so if it has been removed from the document, it will no longer be able to find the math to process. I'll make a test to check that the element is actually found before processing it. That should take care of the problem.

How can I tell MathJax to abort rendering of these elements?

You can't, unfortunately. But it should ignore them (and isn't), so I will fix that. Normally, I'd recommend using MathJax's MathJax.Hub.Queue() command to synchronize your actions (like removing the DOM that MathJax is working on) with the typesetting being performed by MathJax. Pulling the rug out from under MathJax like this can lead to problems. See the documentation for details.

@dpvc dpvc added Accepted labels Feb 6, 2014

dpvc pushed a commit to dpvc/MathJax that referenced this issue Feb 6, 2014

Davide P. Cervone
Add more tests to check that the math is still in the page. Should re…
…solve issue mathjax#730 (though we don't have their page and can't really test it).

dpvc pushed a commit to dpvc/MathJax that referenced this issue Feb 7, 2014

dpvc pushed a commit to dpvc/MathJax that referenced this issue Feb 7, 2014

@dpvc dpvc added Merged and removed Ready for Review labels Feb 7, 2014

@dpvc

This comment has been minimized.

Copy link
Member

commented Feb 7, 2014

=> Merged

@dpvc dpvc closed this Feb 7, 2014

@dpvc dpvc added v2.4 and removed Merged labels Jun 30, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.