1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-02-21 03:41:03 +00:00

Fix color-mode.js

This commit is contained in:
MewenLeHo 2023-09-22 14:31:53 +02:00 committed by Mark Otto
parent d769ae0e0f
commit 73e1dcf43e

View File

@ -20,8 +20,8 @@
}
const setTheme = theme => {
if (theme === 'auto' && window.matchMedia('(prefers-color-scheme: dark)').matches) {
document.documentElement.setAttribute('data-bs-theme', 'dark')
if (theme === 'auto') {
document.documentElement.setAttribute('data-bs-theme', (window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'))
} else {
document.documentElement.setAttribute('data-bs-theme', theme)
}