diff --git a/FixJSDOMEnvironment.ts b/FixJSDOMEnvironment.ts index a257593c4..2911d6262 100644 --- a/FixJSDOMEnvironment.ts +++ b/FixJSDOMEnvironment.ts @@ -26,5 +26,12 @@ export default class FixJSDOMEnvironment extends JSDOMEnvironment { this.global.TextDecoderStream = TextDecoderStream; this.global.URL = URL; this.global.Response = Response; + + /** + * https://github.com/jsdom/jsdom/issues/3766 + * https://github.com/jsdom/jsdom/issues/3444 + */ + this.global.document.adoptedStyleSheets = []; + this.global.CSSStyleSheet.prototype.replaceSync = () => {}; } } diff --git a/src/Themes/ui/Theme.tsx b/src/Themes/ui/Theme.tsx index dcbefa253..13b768594 100644 --- a/src/Themes/ui/Theme.tsx +++ b/src/Themes/ui/Theme.tsx @@ -51,6 +51,7 @@ declare module "@mui/material/styles" { } let theme: Theme; +const themeStyleSheet = new CSSStyleSheet(); export function refreshTheme(): void { theme = createTheme({ @@ -419,7 +420,18 @@ export function refreshTheme(): void { }); document.body.style.backgroundColor = theme.colors.backgroundprimary?.toString() ?? "black"; + + const styleSheet = + ":root {" + + Object.entries(Settings.theme) + .map(([k, v]) => `--bb-theme-${k}: ${v}`) + .join(";") + + "}"; + + themeStyleSheet.replaceSync(styleSheet); } + +document.adoptedStyleSheets.push(themeStyleSheet); refreshTheme(); interface IProps {