Skip to content

Commit 94f8e33

Browse files
committed
fix test
1 parent 3ba9ad8 commit 94f8e33

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

src/utils/browser.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
1-
let windowObject: Window | undefined;
2-
3-
let cachedWindowObject = false;
4-
51
export function getBrowserWindow(): Window | undefined {
6-
if (cachedWindowObject) {
7-
return windowObject;
8-
}
2+
let windowObject: Window | undefined;
93

104
try {
115
windowObject ||= globalThis.window;
6+
if (windowObject) {
7+
return windowObject;
8+
}
129
} catch {
13-
// do nothing
10+
// Check next variable
1411
}
1512

1613
try {
1714
windowObject ||= global.window;
15+
if (windowObject) {
16+
return windowObject;
17+
}
1818
} catch {
19-
// do nothing
19+
// Check next variable
2020
}
2121

2222
try {
2323
windowObject ||= window;
24+
if (windowObject) {
25+
return windowObject;
26+
}
2427
} catch {
25-
// do nothing
28+
// return undefined
2629
}
27-
28-
cachedWindowObject = true;
29-
return windowObject;
3030
}
3131

3232
export function isBrowser(): boolean {

0 commit comments

Comments
 (0)