File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed
src/librustdoc/html/static/js Expand file tree Collapse file tree 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) {
109109} ) ;
110110
111111function 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+
112119 // If this new value comes from a system setting or from the previously
113120 // saved theme, no need to save it.
114121 if ( saveTheme ) {
@@ -123,7 +130,7 @@ function switchTheme(newThemeName, saveTheme) {
123130 window . currentTheme = null ;
124131 }
125132 } else {
126- const newHref = getVar ( "root-path" ) + newThemeName +
133+ const newHref = getVar ( "root-path" ) + encodeURIComponent ( newThemeName ) +
127134 getVar ( "resource-suffix" ) + ".css" ;
128135 if ( ! window . currentTheme ) {
129136 // If we're in the middle of loading, document.write blocks
You can’t perform that action at this time.
0 commit comments