mirror of
https://gitlab.com/PronounsPage/PronounsPage.git
synced 2025-09-24 05:05:20 -04:00
fix $loadScript/$loadStylesheet race condition - CR
This commit is contained in:
parent
2a5399d5a3
commit
54767c7c26
@ -125,6 +125,7 @@ const plugin: Plugin = ({ app, store }, inject) => {
|
|||||||
resolve();
|
resolve();
|
||||||
});
|
});
|
||||||
script.addEventListener('error', (event) => {
|
script.addEventListener('error', (event) => {
|
||||||
|
script.classList.add('loaded'); // not really loaded, but let's stop other calls from waiting forever, see !493
|
||||||
reject(new LoadScriptError(name, src, typeof event === 'string' ? event : event.type));
|
reject(new LoadScriptError(name, src, typeof event === 'string' ? event : event.type));
|
||||||
});
|
});
|
||||||
document.body.appendChild(script);
|
document.body.appendChild(script);
|
||||||
@ -149,8 +150,12 @@ const plugin: Plugin = ({ app, store }, inject) => {
|
|||||||
link.setAttribute('href', src);
|
link.setAttribute('href', src);
|
||||||
link.classList.add(`${name}-stylesheet`);
|
link.classList.add(`${name}-stylesheet`);
|
||||||
link.crossOrigin = 'true';
|
link.crossOrigin = 'true';
|
||||||
link.addEventListener('load', () => resolve());
|
link.addEventListener('load', () => {
|
||||||
|
link.classList.add('loaded');
|
||||||
|
resolve();
|
||||||
|
});
|
||||||
link.addEventListener('error', (event) => {
|
link.addEventListener('error', (event) => {
|
||||||
|
link.classList.add('loaded'); // not really loaded, but let's stop other calls from waiting forever, see !493
|
||||||
reject(new LoadScriptError(name, src, typeof event === 'string' ? event : event.type));
|
reject(new LoadScriptError(name, src, typeof event === 'string' ? event : event.type));
|
||||||
});
|
});
|
||||||
document.body.appendChild(link);
|
document.body.appendChild(link);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user