fix: work around missing indexedDB.databases (#2054)

This commit is contained in:
Nolan Lawson 2021-06-20 09:48:44 -07:00 committed by GitHub
parent e0827be8c8
commit c692a1850b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 1 deletions

View File

@ -6,7 +6,7 @@ import './routes/_utils/forceOnline'
import { mark, stop } from './routes/_utils/marks' import { mark, stop } from './routes/_utils/marks'
import { loadPolyfills } from './routes/_utils/polyfills/loadPolyfills' import { loadPolyfills } from './routes/_utils/polyfills/loadPolyfills'
import { loadNonCriticalPolyfills } from './routes/_utils/polyfills/loadNonCriticalPolyfills' import { loadNonCriticalPolyfills } from './routes/_utils/polyfills/loadNonCriticalPolyfills'
import idbReady from 'safari-14-idb-fix' import { idbReady } from './routes/_utils/idbReady'
Promise.all([idbReady(), loadPolyfills()]).then(() => { Promise.all([idbReady(), loadPolyfills()]).then(() => {
mark('sapperStart') mark('sapperStart')

View File

@ -0,0 +1,14 @@
import safariIdbReady from 'safari-14-idb-fix'
import { isWebKit } from './userAgent/isWebKit'
// workaround for a safari 14 bug, see https://github.com/jakearchibald/safari-14-idb-fix
export async function idbReady () {
if (!isWebKit()) {
return
}
if (typeof indexedDB === 'undefined' || !indexedDB.databases) {
// fix for https://github.com/jakearchibald/safari-14-idb-fix/pull/2
return
}
await safariIdbReady()
}