fix: Properly avoid concurrent invocations of loadMathJax()
.
This commit is contained in:
parent
bdb0dd064b
commit
2d3b9e0c66
@ -123,7 +123,6 @@ const mathJax = {} as {
|
|||||||
amFixes: any;
|
amFixes: any;
|
||||||
};
|
};
|
||||||
|
|
||||||
let stopLoadingMathJax = false;
|
|
||||||
let mathJaxLoaded = false;
|
let mathJaxLoaded = false;
|
||||||
let mathJaxLoading = false;
|
let mathJaxLoading = false;
|
||||||
let mathJaxLoadedCallback: SubtypeLoadedCb | undefined;
|
let mathJaxLoadedCallback: SubtypeLoadedCb | undefined;
|
||||||
@ -135,19 +134,7 @@ let errorSvg: string;
|
|||||||
let errorAria: string;
|
let errorAria: string;
|
||||||
|
|
||||||
const loadMathJax = async () => {
|
const loadMathJax = async () => {
|
||||||
const shouldLoad =
|
const continueLoading = !mathJaxLoading;
|
||||||
!mathJaxLoaded &&
|
|
||||||
!mathJaxLoading &&
|
|
||||||
(mathJax.adaptor === undefined ||
|
|
||||||
mathJax.amHtml === undefined ||
|
|
||||||
mathJax.texHtml === undefined ||
|
|
||||||
mathJax.visitor === undefined ||
|
|
||||||
mathJax.mmlSvg === undefined ||
|
|
||||||
mathJax.amFixes === undefined ||
|
|
||||||
(useSRE && mathJax.mmlSre === undefined));
|
|
||||||
if (!shouldLoad && !mathJaxLoaded) {
|
|
||||||
stopLoadingMathJax = true;
|
|
||||||
}
|
|
||||||
if (!mathJaxLoaded) {
|
if (!mathJaxLoaded) {
|
||||||
mathJaxLoading = true;
|
mathJaxLoading = true;
|
||||||
|
|
||||||
@ -208,8 +195,7 @@ const loadMathJax = async () => {
|
|||||||
type E = typeof LiteElement;
|
type E = typeof LiteElement;
|
||||||
type T = typeof LiteText;
|
type T = typeof LiteText;
|
||||||
type D = typeof LiteDocument;
|
type D = typeof LiteDocument;
|
||||||
if (stopLoadingMathJax) {
|
if (mathJaxLoading && !continueLoading) {
|
||||||
stopLoadingMathJax = false;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user