Skip to content

Commit

Permalink
remove sanitization from initial tag
Browse files Browse the repository at this point in the history
  • Loading branch information
huntabyte committed Jul 14, 2024
1 parent aa1759c commit 5145f5c
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions packages/mode-watcher/src/lib/mode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
themeColors,
disableTransitions,
} from './stores.js';
import { sanitizeClassNames } from './utils.js';
import type { Mode, ThemeColors } from './types.js';

/** Toggle between light and dark mode */
Expand Down Expand Up @@ -37,14 +36,12 @@ export function setInitialMode(
const light =
mode === 'light' ||
(mode === 'system' && window.matchMedia('(prefers-color-scheme: light)').matches);
const sanitizedDarkClassNames = sanitizeClassNames(darkClassNames);
const sanitizedLightClassNames = sanitizeClassNames(lightClassNames);
if (light) {
if (sanitizedDarkClassNames.length) rootEl.classList.remove(...sanitizedDarkClassNames);
if (sanitizedLightClassNames.length) rootEl.classList.add(...sanitizedLightClassNames);
if (darkClassNames.length) rootEl.classList.remove(...darkClassNames);
if (lightClassNames.length) rootEl.classList.add(...lightClassNames);
} else {
if (sanitizedLightClassNames.length) rootEl.classList.remove(...sanitizedLightClassNames);
if (sanitizedDarkClassNames.length) rootEl.classList.add(...sanitizedDarkClassNames);
if (lightClassNames.length) rootEl.classList.remove(...lightClassNames);
if (darkClassNames.length) rootEl.classList.add(...darkClassNames);
}
rootEl.style.colorScheme = light ? 'light' : 'dark';

Expand Down

0 comments on commit 5145f5c

Please sign in to comment.