From 5ae08050adcbce28135614ce5234b7ec2ee113c6 Mon Sep 17 00:00:00 2001 From: Kognise Date: Fri, 5 Apr 2019 09:21:05 -0400 Subject: [PATCH] Update theme switching code --- docs/script.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/script.js b/docs/script.js index 0c34b6b..ea670de 100644 --- a/docs/script.js +++ b/docs/script.js @@ -1,11 +1,11 @@ document.getElementById('switch').addEventListener('click', () => { const { body } = document const ph = document.getElementById('ph') - if (body.className) { - body.className = '' + if (body.classList.contains('light')) { + body.classList.remove('light') ph.src = ph.src.replace('theme=light', 'theme=dark') } else { - body.className = 'light' + body.classList.add('light') ph.src = ph.src.replace('theme=dark', 'theme=light') } }) \ No newline at end of file