File tree Expand file tree Collapse file tree 1 file changed +13
-13
lines changed Expand file tree Collapse file tree 1 file changed +13
-13
lines changed Original file line number Diff line number Diff line change 1
- let windowObject : Window | undefined ;
2
-
3
- let cachedWindowObject = false ;
4
-
5
1
export function getBrowserWindow ( ) : Window | undefined {
6
- if ( cachedWindowObject ) {
7
- return windowObject ;
8
- }
2
+ let windowObject : Window | undefined ;
9
3
10
4
try {
11
5
windowObject ||= globalThis . window ;
6
+ if ( windowObject ) {
7
+ return windowObject ;
8
+ }
12
9
} catch {
13
- // do nothing
10
+ // Check next variable
14
11
}
15
12
16
13
try {
17
14
windowObject ||= global . window ;
15
+ if ( windowObject ) {
16
+ return windowObject ;
17
+ }
18
18
} catch {
19
- // do nothing
19
+ // Check next variable
20
20
}
21
21
22
22
try {
23
23
windowObject ||= window ;
24
+ if ( windowObject ) {
25
+ return windowObject ;
26
+ }
24
27
} catch {
25
- // do nothing
28
+ // return undefined
26
29
}
27
-
28
- cachedWindowObject = true ;
29
- return windowObject ;
30
30
}
31
31
32
32
export function isBrowser ( ) : boolean {
You can’t perform that action at this time.
0 commit comments