From 7eb46ab864f6523cc025f82587623d7789097201 Mon Sep 17 00:00:00 2001 From: Jesper Orb Date: Sat, 23 Mar 2024 14:04:16 +0100 Subject: [PATCH] fix: apply dark mode on body --- src/lib/components/ui/DarkModeToggle.svelte | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lib/components/ui/DarkModeToggle.svelte b/src/lib/components/ui/DarkModeToggle.svelte index 25fb04b..d30e731 100644 --- a/src/lib/components/ui/DarkModeToggle.svelte +++ b/src/lib/components/ui/DarkModeToggle.svelte @@ -12,12 +12,12 @@ const change = (event: Event) => { const target = event.target as HTMLInputElement; - const body = browser ? document.querySelector('body') : null; - if (body) { + const element = browser ? document.querySelector('html') : null; + if (element) { if (target.checked) { - body.setAttribute('data-dark-mode', 'true'); + element.setAttribute('data-dark-mode', 'true'); } else { - body.removeAttribute('data-dark-mode'); + element.removeAttribute('data-dark-mode'); } } };