wobsoriano / svelte-sonner

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

Cannot work with sveltekit deployed to deno #51

Open yangg opened 7 months ago

yangg commented 7 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 7 months ago

Are you still getting that issue?