From cc33297cc48e86614da34cffedfb77080e02e7af Mon Sep 17 00:00:00 2001 From: tageniu Date: Mon, 30 Mar 2026 18:16:15 -0400 Subject: [PATCH] fix(controller): check html and body data attrs independently Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- packages/page-controller/src/mask/checkDarkMode.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/page-controller/src/mask/checkDarkMode.ts b/packages/page-controller/src/mask/checkDarkMode.ts index b20fb51..92e666c 100644 --- a/packages/page-controller/src/mask/checkDarkMode.ts +++ b/packages/page-controller/src/mask/checkDarkMode.ts @@ -18,8 +18,10 @@ function hasDarkModeClass() { // Some sites use data attributes (data-theme, data-color-mode, data-bs-theme, etc.) const dataAttrs = ['data-theme', 'data-color-mode', 'data-bs-theme', 'data-color-scheme'] for (const attr of dataAttrs) { - const value = htmlElement.getAttribute(attr) || bodyElement?.getAttribute(attr) - if (value?.toLowerCase().includes('dark')) { + const bodyValue = bodyElement?.getAttribute(attr) + const htmlValue = htmlElement.getAttribute(attr) + + if (bodyValue?.toLowerCase().includes('dark') || htmlValue?.toLowerCase().includes('dark')) { return true } }