Skip to content

Commit bbafda4

Browse files
committed
fix(getThemeModeScript): wrap classsName in proper string tags
1 parent cf98442 commit bbafda4

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

packages/ui/src/theme/mode-script.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@ describe("ThemeModeScript", () => {
3737
const { container } = render(<ThemeModeScript prefix="custom-" version={3} />);
3838
const script = container.querySelector("script");
3939

40-
expect(script?.innerHTML).toContain("custom-dark");
40+
expect(script?.innerHTML).toContain('const className = "custom-dark"');
4141
});
4242

4343
it("should not include prefix when version is 4", () => {
4444
const { container } = render(<ThemeModeScript prefix="custom-" version={4} />);
4545
const script = container.querySelector("script");
4646

47-
expect(script?.innerHTML).toContain("dark");
47+
expect(script?.innerHTML).toContain('const className = "dark"');
4848
});
4949
});

packages/ui/src/theme/mode-script.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ export function getThemeModeScript(
117117
const resolvedMode = (isStorageModeValid ? storageMode : null) ?? ${mode ? `"${mode}"` : undefined} ?? "${defaultMode}";
118118
const computedMode =
119119
resolvedMode === "auto" ? (window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light") : resolvedMode;
120-
const className = ${version === 3 ? `"${prefix}dark"` : "dark"};
120+
const className = ${version === 3 ? `"${prefix}dark"` : `"dark"`};
121121
122122
if (computedMode === "dark") {
123123
document.documentElement.classList.add(className);

0 commit comments

Comments
 (0)