web/polyfills: add polyfill for AbortSignal.timeout

This commit is contained in:
dumbmoron 2024-09-21 09:08:45 +00:00
parent 819c7a4fa0
commit 5ba83f3d56
No known key found for this signature in database
2 changed files with 11 additions and 0 deletions

View file

@ -1 +1,2 @@
import "./polyfills/user-activation"; import "./polyfills/user-activation";
import "./polyfills/abortsignal-timeout";

View file

@ -0,0 +1,10 @@
import { browser } from "$app/environment";
if (browser && 'AbortSignal' in window && !window.AbortSignal.timeout) {
window.AbortSignal.timeout = (milliseconds: number) => {
const controller = new AbortController();
setTimeout(() => controller.abort("timed out"), milliseconds);
return controller.signal;
}
}