File tree 1 file changed +8
-1
lines changed
src/librustdoc/html/static/js
1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -109,6 +109,13 @@ const getVar = (function getVar(name) {
109
109
} ) ;
110
110
111
111
function switchTheme ( newThemeName , saveTheme ) {
112
+ const theme_names = getVar ( "themes" ) . split ( "," ) . filter ( t => t ) ;
113
+ theme_names . push ( "light" , "dark" , "ayu" ) ;
114
+
115
+ if ( theme_names . indexOf ( newThemeName ) == - 1 ) {
116
+ return ;
117
+ }
118
+
112
119
// If this new value comes from a system setting or from the previously
113
120
// saved theme, no need to save it.
114
121
if ( saveTheme ) {
@@ -123,7 +130,7 @@ function switchTheme(newThemeName, saveTheme) {
123
130
window . currentTheme = null ;
124
131
}
125
132
} else {
126
- const newHref = getVar ( "root-path" ) + newThemeName +
133
+ const newHref = getVar ( "root-path" ) + encodeURIComponent ( newThemeName ) +
127
134
getVar ( "resource-suffix" ) + ".css" ;
128
135
if ( ! window . currentTheme ) {
129
136
// If we're in the middle of loading, document.write blocks
You can’t perform that action at this time.
0 commit comments