File tree Expand file tree Collapse file tree 3 files changed +12
-3
lines changed Expand file tree Collapse file tree 3 files changed +12
-3
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ ' @firebase/app-compat ' : patch
3
+ ---
4
+
5
+ Handle JSDOM case in app-compat checks.
Original file line number Diff line number Diff line change 16
16
*/
17
17
18
18
import { FirebaseNamespace } from './public-types' ;
19
- import { isBrowser } from '@firebase/util' ;
19
+ import { isBrowser , getGlobal } from '@firebase/util' ;
20
20
import { firebase as firebaseNamespace } from './firebaseNamespace' ;
21
21
import { logger } from './logger' ;
22
22
import { registerCoreComponents } from './registerCoreComponents' ;
23
23
24
24
// Firebase Lite detection
25
25
// eslint-disable-next-line @typescript-eslint/no-explicit-any
26
- if ( isBrowser ( ) && ( self as any ) . firebase !== undefined ) {
26
+ if ( isBrowser ( ) && ( getGlobal ( ) as any ) . firebase !== undefined ) {
27
27
logger . warn ( `
28
28
Warning: Firebase is already defined in the global scope. Please make sure
29
29
Firebase library is only loaded once.
30
30
` ) ;
31
31
32
32
// eslint-disable-next-line
33
- const sdkVersion = ( ( self as any ) . firebase as FirebaseNamespace ) . SDK_VERSION ;
33
+ const sdkVersion = ( ( getGlobal ( ) as any ) . firebase as FirebaseNamespace )
34
+ . SDK_VERSION ;
34
35
if ( sdkVersion && sdkVersion . indexOf ( 'LITE' ) >= 0 ) {
35
36
logger . warn ( `
36
37
Warning: You are trying to load Firebase while using Firebase Performance standalone script.
Original file line number Diff line number Diff line change @@ -80,6 +80,9 @@ export function isNode(): boolean {
80
80
81
81
/**
82
82
* Detect Browser Environment
83
+ * Note: This will return true for JSDOM (e.g. Jest) as it is mimicking
84
+ * a browser, and should not lead to assuming all browser APIs are
85
+ * available.
83
86
*/
84
87
export function isBrowser ( ) : boolean {
85
88
return typeof window !== 'undefined' || isWebWorker ( ) ;
You can’t perform that action at this time.
0 commit comments