From 497e02276c51b33ed6b413b6ee7c682178d27f15 Mon Sep 17 00:00:00 2001 From: Radoslav Karaivanov Date: Fri, 25 Oct 2024 10:43:56 +0300 Subject: [PATCH] refactor: Themes emitter SSR initialization (#1449) --- src/theming/theming-event.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/theming/theming-event.ts b/src/theming/theming-event.ts index 67956e6d8..1ef4498f3 100644 --- a/src/theming/theming-event.ts +++ b/src/theming/theming-event.ts @@ -1,9 +1,12 @@ +import { isServer } from 'lit'; import type { Theme, ThemeVariant } from './types.js'; class ThemeChangedEmitter extends EventTarget { constructor() { super(); - globalThis.addEventListener(CHANGE_THEME_EVENT, this); + if (!isServer) { + globalThis.addEventListener(CHANGE_THEME_EVENT, this); + } } public handleEvent() {