()
| 421 | const html = document.documentElement |
| 422 | const mql = window.matchMedia('(prefers-color-scheme: dark)') |
| 423 | const apply = (): void => { |
| 424 | const prefersDark = mql.matches |
| 425 | if (isCustomThemeId(themeId)) { |
| 426 | const slug = customThemeSlugFromId(themeId) |
| 427 | const theme = customThemes.find((t) => t.slug === slug) |
| 428 | const wantDark = themeMode === 'auto' ? prefersDark : themeMode === 'dark' |
| 429 | html.dataset.theme = themeId |
| 430 | html.dataset.themeMode = resolveCustomThemeMode(theme, wantDark) |
| 431 | } else { |
| 432 | const id = themeMode === 'auto' ? resolveAuto(themeFamily, prefersDark, themeId) : themeId |
| 433 | html.dataset.theme = id |
| 434 | html.dataset.themeMode = findTheme(id).mode |
| 435 | } |
| 436 | } |
| 437 | apply() |
| 438 | if (themeMode === 'auto') { |
| 439 | mql.addEventListener('change', apply) |
no test coverage detected