Skip to content

Commit 678337a

Browse files
fix: adds resize observer check (#135)
1 parent fea8c46 commit 678337a

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/index.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,10 +240,16 @@ let mutations: MutationObserver | undefined
240240
*/
241241
let resize: ResizeObserver | undefined
242242

243+
/**
244+
* Ensure the browser is supported.
245+
*/
246+
const supportedBrowser =
247+
typeof window !== "undefined" && "ResizeObserver" in window
248+
243249
/**
244250
* If this is in a browser, initialize our Web APIs
245251
*/
246-
if (typeof window !== "undefined") {
252+
if (supportedBrowser) {
247253
root = document.documentElement
248254
mutations = new MutationObserver(handleMutations)
249255
resize = new ResizeObserver(handleResizes)

0 commit comments

Comments
 (0)