mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-05 20:57:12 +00:00
fix: validate persisted theme value before applying
This commit is contained in:
parent
070898108f
commit
f5b1705925
1 changed files with 2 additions and 1 deletions
|
|
@ -6,7 +6,8 @@
|
||||||
} catch {
|
} catch {
|
||||||
// storage unavailable (private mode, quota exceeded)
|
// storage unavailable (private mode, quota exceeded)
|
||||||
}
|
}
|
||||||
const theme = stored || (window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light');
|
const storedTheme = ['light', 'dark'].includes(stored) ? stored : null;
|
||||||
|
const theme = storedTheme || (window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light');
|
||||||
document.documentElement.setAttribute('data-bs-theme', theme);
|
document.documentElement.setAttribute('data-bs-theme', theme);
|
||||||
})();
|
})();
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue