File tree Expand file tree Collapse file tree 2 files changed +4
-2
lines changed Expand file tree Collapse file tree 2 files changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -643,7 +643,8 @@ var DarkMode = {
643
643
theme = document . documentElement . dataset . theme === "dark" ? "light" : "dark"
644
644
}
645
645
document . documentElement . dataset . theme = theme
646
- localStorage . setItem ( "theme" , theme ) ;
646
+ if ( prefersDarkScheme === ( theme === "dark" ) ) localStorage . removeItem ( "theme" ) ;
647
+ else localStorage . setItem ( "theme" , theme ) ;
647
648
button . attr ( "src" , `${ baseURLPrefix } images/${ theme === "dark" ? "light" : "dark" } -mode.svg` ) ;
648
649
} ) ;
649
650
} ,
Original file line number Diff line number Diff line change @@ -49,7 +49,8 @@ <h1>Redirecting…</h1>
49
49
if ( currentTheme ) {
50
50
// Check dark mode preference at the OS level
51
51
const prefersDarkScheme = window . matchMedia ( "(prefers-color-scheme: dark)" ) . matches
52
- if ( ( prefersDarkScheme && currentTheme === "light" )
52
+ if ( prefersDarkScheme === ( currentTheme === "dark" ) ) localStorage . removeItem ( "theme" )
53
+ else if ( ( prefersDarkScheme && currentTheme === "light" )
53
54
|| ( ! prefersDarkScheme && currentTheme === "dark" ) ) {
54
55
document . documentElement . dataset . theme = currentTheme
55
56
}
You can’t perform that action at this time.
0 commit comments