File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed
src/librustdoc/html/static Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change 11// From rust:
22/* global resourcesSuffix */
33
4+ var darkThemes = [ "dark" , "ayu" ] ;
45var currentTheme = document . getElementById ( "themeStyle" ) ;
56var mainTheme = document . getElementById ( "mainThemeStyle" ) ;
7+ var localStoredTheme = getCurrentValue ( "rustdoc-theme" ) ;
68
79var savedHref = [ ] ;
810
@@ -179,6 +181,14 @@ var updateSystemTheme = (function() {
179181} ) ( ) ;
180182
181183if ( getCurrentValue ( "rustdoc-use-system-theme" ) !== "false" && window . matchMedia ) {
184+ // update the preferred dark theme if the user is already using a dark theme
185+ // See https://github.com/rust-lang/rust/pull/77809#issuecomment-707875732
186+ if ( getCurrentValue ( "rustdoc-use-system-theme" ) === null
187+ && getCurrentValue ( "rustdoc-preferred-dark-theme" ) === null
188+ && darkThemes . indexOf ( localStoredTheme ) >= 0 ) {
189+ updateLocalStorage ( "rustdoc-preferred-dark-theme" , localStoredTheme ) ;
190+ }
191+
182192 // call the function to initialize the theme at least once!
183193 updateSystemTheme ( ) ;
184194} else {
You can’t perform that action at this time.
0 commit comments