Internal change
PiperOrigin-RevId: 488294157
This commit is contained in:
parent
6c0ca947de
commit
8d9cdb86dc
|
@ -970,8 +970,17 @@ async function runScript(scriptUrl: string) {
|
||||||
if (typeof importScripts === 'function') {
|
if (typeof importScripts === 'function') {
|
||||||
importScripts(scriptUrl.toString());
|
importScripts(scriptUrl.toString());
|
||||||
} else {
|
} else {
|
||||||
await new Promise((resolve, reject) => {
|
const script = document.createElement('script');
|
||||||
fetch(scriptUrl).then(response => response.text()).then(text => Function(text)).then(resolve, reject);
|
script.setAttribute('url', scriptUrl);
|
||||||
|
script.setAttribute('crossorigin', 'anonymous');
|
||||||
|
return new Promise<void>((resolve) => {
|
||||||
|
script.addEventListener('load', () => {
|
||||||
|
resolve();
|
||||||
|
}, false);
|
||||||
|
script.addEventListener('error', () => {
|
||||||
|
resolve();
|
||||||
|
}, false);
|
||||||
|
document.body.appendChild(script);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user