mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-03-21 05:18:51 +01:00
Add AbortSignal.timeout polyfill
This commit is contained in:
parent
e153f9f541
commit
c538cfeaaa
1 changed files with 13 additions and 0 deletions
13
src/main.jsx
13
src/main.jsx
|
@ -11,6 +11,19 @@ if (import.meta.env.DEV) {
|
||||||
import('preact/debug');
|
import('preact/debug');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AbortSignal.timeout polyfill
|
||||||
|
// Temporary fix from https://github.com/mo/abortcontroller-polyfill/issues/73#issuecomment-1541180943
|
||||||
|
// Incorrect implementation, but should be good enough for now
|
||||||
|
if ('AbortSignal' in window) {
|
||||||
|
AbortSignal.timeout =
|
||||||
|
AbortSignal.timeout ||
|
||||||
|
((duration) => {
|
||||||
|
const controller = new AbortController();
|
||||||
|
setTimeout(() => controller.abort(), duration);
|
||||||
|
return controller.signal;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
render(
|
render(
|
||||||
<HashRouter>
|
<HashRouter>
|
||||||
<App />
|
<App />
|
||||||
|
|
Loading…
Reference in a new issue