forked from sveltejs/svelte
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: add polyfills / avoid using
structuredClone
(sveltejs#915)
- polyfills for `at` and `withResolvers` - avoid using `structuredClone`, we can use `JSON.parse(JSON.stringify(..))` instead at that position makes the site work in more browsers closes sveltejs#911
- Loading branch information
1 parent
c8f62af
commit 0d2d24f
Showing
7 changed files
with
27 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import '@sveltejs/site-kit/polyfills'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Some polyfills for things used throughout the app for better browser compat | ||
|
||
if (!Array.prototype.at) { | ||
Array.prototype.at = /** @param {number} index */ function (index) { | ||
return this[index >= 0 ? index : this.length + index]; | ||
}; | ||
} | ||
|
||
if (!Promise.withResolvers) { | ||
Promise.withResolvers = function () { | ||
let resolve: any, reject: any; | ||
const promise = new Promise<any>((res, rej) => { | ||
resolve = res; | ||
reject = rej; | ||
}); | ||
return { resolve, reject, promise }; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters