Skip to content

Commit d4ca3da

Browse files
authored
Extended Usage of isIndexedDBAvailable to Service Worker (#3585)
* extended usage of isIndexedDBAvailable to service worker * Create silly-moles-rush.md * Update silly-moles-rush.md
1 parent d3f2507 commit d4ca3da

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

.changeset/silly-moles-rush.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"firebase": patch
3+
"@firebase/util": patch
4+
---
5+
6+
Extended Usage of `isIndexedDBAvailable` to Service Worker

packages/util/src/environment.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,14 +136,11 @@ export function isSafari(): boolean {
136136
}
137137

138138
/**
139-
* This method checks if indexedDB is supported by current browser
140-
* @return true if indexedDB is supported by current browser
139+
* This method checks if indexedDB is supported by current browser/service worker context
140+
* @return true if indexedDB is supported by current browser/service worker context
141141
*/
142142
export function isIndexedDBAvailable(): boolean {
143-
if (!('indexedDB' in window) || indexedDB === null) {
144-
return false;
145-
}
146-
return true;
143+
return 'indexedDB' in self && indexedDB !== null;
147144
}
148145

149146
/**

0 commit comments

Comments
 (0)