Skip to content

Commit 9c12d71

Browse files
authored
Check typeof DOMException !== 'undefined'
1 parent a8be6ed commit 9c12d71

File tree

1 file changed

+4
-1
lines changed
  • packages/firestore/src/platform/browser

1 file changed

+4
-1
lines changed

packages/firestore/src/platform/browser/base64.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ export function decodeBase64(encoded: string): string {
2222
try {
2323
return atob(encoded);
2424
} catch (e) {
25-
if (e instanceof DOMException) {
25+
// Check that `DOMException` is defined before using it to avoid
26+
// "ReferenceError: Property 'DOMException' doesn't exist" in react-native.
27+
// (https://github.com/firebase/firebase-js-sdk/issues/7115)
28+
if (typeof DOMException !== 'undefined' && e instanceof DOMException) {
2629
throw new Base64DecodeError('Invalid base64 string: ' + e);
2730
} else {
2831
throw e;

0 commit comments

Comments
 (0)