diff --git a/fixtures/input/astro.astro b/fixtures/input/astro.astro index df4e8e5ef7..21812eabe2 100644 --- a/fixtures/input/astro.astro +++ b/fixtures/input/astro.astro @@ -18,4 +18,21 @@ const content = "hi!"; document.querySelector('h1')?.addEventListener('click', () => { logger('clicked'); }); + + function someFunction() { + const theme = (() => { + if ( + typeof localStorage !== 'undefined' && localStorage.getItem('theme') + ) { + return localStorage.getItem('theme') + } + })() + if (theme === 'light') { + document.documentElement.classList.remove('dark') + } else { + document.documentElement.classList.add('dark') + } + return + } + someFunction() diff --git a/fixtures/output/all/astro.astro b/fixtures/output/all/astro.astro index b67c6784ea..74563cbf56 100644 --- a/fixtures/output/all/astro.astro +++ b/fixtures/output/all/astro.astro @@ -18,4 +18,22 @@ const { log: logger } = console document.querySelector('h1')?.addEventListener('click', () => { logger('clicked') }) + +function someFunction() { + const theme = (() => { + if ( + typeof localStorage !== 'undefined' + && localStorage.getItem('theme') + ) { + return localStorage.getItem('theme') + } + })() + if (theme === 'light') { + document.documentElement.classList.remove('dark') + } + else { + document.documentElement.classList.add('dark') + } +} +someFunction()