File tree 3 files changed +13
-3
lines changed
3 files changed +13
-3
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ ' @firebase/firestore ' : patch
3
+ ' firebase ' : patch
4
+ ---
5
+
6
+ Fix 'window is not defined' error when calling ` clearIndexedDbPersistence ` from a service worker
Original file line number Diff line number Diff line change 31
31
" packages/util/dist/src/emulator.d.ts" ,
32
32
" packages/util/dist/src/environment.d.ts" ,
33
33
" packages/util/dist/src/compat.d.ts" ,
34
+ " packages/util/dist/src/global.d.ts" ,
34
35
" packages/util/dist/src/obj.d.ts" ,
35
36
" packages/firestore/src/protos/firestore_bundle_proto.ts" ,
36
37
" packages/firestore/src/protos/firestore_proto_api.ts" ,
Original file line number Diff line number Diff line change 15
15
* limitations under the License.
16
16
*/
17
17
18
- import { getUA , isIndexedDBAvailable } from '@firebase/util' ;
18
+ import { getGlobal , getUA , isIndexedDBAvailable } from '@firebase/util' ;
19
19
20
20
import { debugAssert } from '../util/assert' ;
21
21
import { Code , FirestoreError } from '../util/error' ;
@@ -24,7 +24,7 @@ import { Deferred } from '../util/promise';
24
24
25
25
import { PersistencePromise } from './persistence_promise' ;
26
26
27
- // References to `window ` are guarded by SimpleDb.isAvailable()
27
+ // References to `indexedDB ` are guarded by SimpleDb.isAvailable() and getGlobal ()
28
28
/* eslint-disable no-restricted-globals */
29
29
30
30
const LOG_TAG = 'SimpleDb' ;
@@ -164,7 +164,10 @@ export class SimpleDb {
164
164
/** Deletes the specified database. */
165
165
static delete ( name : string ) : Promise < void > {
166
166
logDebug ( LOG_TAG , 'Removing database:' , name ) ;
167
- return wrapRequest < void > ( window . indexedDB . deleteDatabase ( name ) ) . toPromise ( ) ;
167
+ const globals = getGlobal ( ) ;
168
+ return wrapRequest < void > (
169
+ globals . indexedDB . deleteDatabase ( name )
170
+ ) . toPromise ( ) ;
168
171
}
169
172
170
173
/** Returns true if IndexedDB is available in the current environment. */
You can’t perform that action at this time.
0 commit comments