From 253d378bc004de3af4910b24bcd3695190fed59f Mon Sep 17 00:00:00 2001 From: Ramsay Leung Date: Wed, 4 Dec 2024 11:49:52 +0800 Subject: [PATCH] Fix redeclaration problem of observer variable. --- layouts/partials/comments.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/layouts/partials/comments.html b/layouts/partials/comments.html index 003fbec8..27603498 100644 --- a/layouts/partials/comments.html +++ b/layouts/partials/comments.html @@ -33,7 +33,7 @@

Comments

loadUtterances(isDarkMode); // Watch for theme changes -const observer = new MutationObserver((mutations) => { +const themeObserver = new MutationObserver((mutations) => { mutations.forEach((mutation) => { if (mutation.type === 'attributes' && mutation.attributeName === 'class') { const isDarkMode = getCurrentTheme() === 'dark'; @@ -44,7 +44,7 @@

Comments

}); // Start observing the body element for class changes -observer.observe(document.body, { +themeObserver.observe(document.body, { attributes: true, attributeFilter: ['class'] });