From 1b845da360f2de4ad78c97b032a9c0bf26ce1f5b Mon Sep 17 00:00:00 2001 From: Hatem Hosny Date: Sat, 17 Feb 2024 15:26:56 +0200 Subject: [PATCH] fix(Embed): fix setting on undefined (theme toggle in embeds) --- src/livecodes/core.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/livecodes/core.ts b/src/livecodes/core.ts index 6d11763e4..00ee78bf3 100644 --- a/src/livecodes/core.ts +++ b/src/livecodes/core.ts @@ -1650,7 +1650,10 @@ const setTheme = (theme: Theme, editorTheme: Config['editorTheme']) => { const root = document.querySelector(':root'); root?.classList.remove(...themes); root?.classList.add(theme); - UI.getThemeToggle().checked = theme === 'dark'; + const themeToggle = UI.getThemeToggle(); + if (themeToggle) { + themeToggle.checked = theme === 'dark'; + } getAllEditors().forEach((editor) => { editor?.setTheme(theme, editorTheme); customEditors[editor?.getLanguage()]?.setTheme(theme);