You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(docs): darkModeControl overwrites document.body.className instead of using classList.add #1930
When initializing dark mode from localStorage, the code sets document.body.className = 'dark' directly rather than calling document.body.classList.add('dark'). This clobbers all other classes that may already be present on <body> (such as layout, accessibility, or browser extension classes). The event listener itself correctly uses classList.add('dark') and classList.remove('dark').
Steps To Reproduce
In the browser console, run localStorage.setItem('animate-css', 'dark').
Add a class to body, e.g. <body class="custom-layout">.
Reload the page and let darkModeControl() run.
Inspect document.body.className.
Notice custom-layout has been erased and replaced with "dark".
Expected Behavior
document.body.classList.add('dark') should be used so existing body classes are preserved ("custom-layout dark").
Screenshots
No response
Desktop
OS: Any
Browser: Any modern browser
Smartphone
Device: Any
Browser: Any
Additional Context
Suggested fix:
In docs/modules/darkMode.mjs line 15, change:
Activity