Skip to content

Commit 50c5c8b

Browse files
fix: ensure window.matchMedia is defined as function (#138)
Co-authored-by: Hunter Johnston <64506580+huntabyte@users.noreply.github.com>
1 parent 6c7951f commit 50c5c8b

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

.changeset/silly-rooms-care.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"mode-watcher": patch
3+
---
4+
5+
fix: ensure `window.matchMedia` is defined as function before calling

packages/mode-watcher/src/lib/mode-states.svelte.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export class SystemPrefersMode {
5555
#track = true;
5656
#current = $state<SystemModeValue>(this.#defaultValue);
5757
#mediaQueryState =
58-
typeof window !== "undefined" && "matchMedia" in window
58+
typeof window !== "undefined" && typeof window.matchMedia === "function"
5959
? new MediaQuery("prefers-color-scheme: light")
6060
: { current: false };
6161

0 commit comments

Comments
 (0)