-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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 4: startup.promise resolves before DOM has time to update #3131
Comments
When I substitute Can you try that URL to see if that works for you? |
Yes it works with Mathjax 3. It does not work in Mathjax 4. Try with |
OOPS, sorry. Working on answering too many different issues! It turns out that this is the same issue as #3130: the window.MathJax = {
startup: {
ready: () => {
window.MathJax.startup.defaultReady();
window.MathJax.startup.promise.then(() => {
turnRed();
});
},
pageReady() {
const CONFIG = MathJax.config.startup;
const output = MathJax.config.output;
return (CONFIG.loadAllFontFiles && output.font ? output.font.loadDynamicFiles() : Promise.resolve())
.then(CONFIG.typeset && MathJax.typesetPromise ?
() => MathJax.startup.typesetPromise(CONFIG.elements) : Promise.resolve());
}
}
}; as the configuration (this in-lines the correct `defaultPageReady()` function). I've already made a PR for the correction that resolve this. |
Thanks for the update. I guess we will just wait until you fixed this in an actual release instead of working around it ourselves just to remove the workaround at the next best moment. |
OK, very good. We should have beta.5 soon and hope to have the official 4.0 release by the end of the year. |
Is there any update on the roadmap? We are inclined to go with the workaround and stick with beta.4. Our goal is to decide upon a mathjax version before the end of the month. |
As you can see, the release didn't happen as we had hoped. The updates to the expression explorer (that would lead to the beta.5 release) have taken longer than expected, and have push everything back. It is likely to still be several months before the official 4.0. |
Issue Summary
Using
startup.promise.then()
to do post-typesetting adjustments to DOM elements, we mentioned that in MathJax 4 our document.querySelector()s of mjx elements retrieve no elements. Sometimes though, after several random reloads trying to find our error, we actually do get them. This lead us to believe that the promise resolves before the elements are added to the DOM or rather that the promise resolves before the DOM has had time to mention the update, as turning our post-typeset callbacks into renderActions actually tells us that the elements we are interested in are indeed part of the DOM. It feels like the querySelectors should be able to find the items, but they do not. It looks like the promise resolving our callback happens before the actual typeset is complete.Steps to Reproduce:
document.querySelectorAll('mjx-container svg g[data-mml-node="mtable"]:first-of-type > g[data-mml-node="mtr"]')
Technical details:
I am using a MathJax configuration that is irrelevant to the issue.
and loading MathJax via
Supporting information:
Here you have a minimal page you can test the issue with:
What I expect to happen?
turnRed gets called after typesetting and turn each row of the equation red
What happens?
Nothing happens after typesetting. Pressing the "Turn Red" button after the page loaded and a bit of time passed does work though. Changing the callback from
turnRed();
tosetTimeout(turnRed, 1);
also works.The text was updated successfully, but these errors were encountered: