Skip to content

Commit

Permalink
fix: adds resize observer check (#135)
Browse files Browse the repository at this point in the history
  • Loading branch information
justin-schroeder committed Apr 10, 2024
1 parent fea8c46 commit 678337a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,10 +240,16 @@ let mutations: MutationObserver | undefined
*/
let resize: ResizeObserver | undefined

/**
* Ensure the browser is supported.
*/
const supportedBrowser =
typeof window !== "undefined" && "ResizeObserver" in window

/**
* If this is in a browser, initialize our Web APIs
*/
if (typeof window !== "undefined") {
if (supportedBrowser) {
root = document.documentElement
mutations = new MutationObserver(handleMutations)
resize = new ResizeObserver(handleResizes)
Expand Down

0 comments on commit 678337a

Please sign in to comment.