wobsoriano / svelte-sonner

An opinionated toast component for Svelte. A port of @emilkowalski's sonner.
https://svelte-sonner.vercel.app
MIT License
705 stars 23 forks source link

Cannot work with sveltekit deployed to deno #51

Open yangg opened 9 months ago

yangg commented 9 months ago

Describe the bug

TypeError: window.matchMedia is not a function
    at file:///src/server.js:1105:20
    at Object.$$render (file:///src/server.js:184:18)
    at file:///src/server.js:1174:55
$: {
    if (theme !== 'system') {
        actualTheme = theme;
    }
    if (typeof window !== 'undefined') {
        if (theme === 'system') {
            // check if current preference is dark
            if (window.matchMedia &&
                window.matchMedia('(prefers-color-scheme: dark)').matches) {
                // it's currently dark
                actualTheme = 'dark';
            }
            else {
                // it's not dark
                actualTheme = 'light';
            }
        }
 //  next line is 1105
        window
            .matchMedia('(prefers-color-scheme: dark)')
            .addEventListener('change', ({ matches }) => {
            actualTheme = matches ? 'dark' : 'light';
        });
    }
}

Reproduction

deploy to deno

Logs

No response

System Info

1

Severity

annoyance

wobsoriano commented 9 months ago

Are you still getting that issue?