File tree Expand file tree Collapse file tree 2 files changed +11
-5
lines changed Expand file tree Collapse file tree 2 files changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -361,13 +361,17 @@ function playground_text(playground, hidden = true) {
361361 } ) ;
362362 }
363363
364- var previousTheme = get_theme ( ) ;
364+ var previousTheme = get_theme ( ) . replace ( / \W + / g, '_' ) . toLowerCase ( ) ;
365+ var selectedTheme = theme . replace ( / \W + / g, '_' ) . toLowerCase ( ) ;
365366 if ( store ) {
366367 try { localStorage . setItem ( 'mdbook-theme' , theme ) ; } catch ( e ) { }
367368 }
368369
369- html . classList . remove ( previousTheme . replace ( / \W + / g, '_' ) . toLowerCase ( ) ) ;
370- html . classList . add ( theme . replace ( / \W + / g, '_' ) . toLowerCase ( ) ) ;
370+ try {
371+ html . classList . remove ( previousTheme ) ;
372+ html . classList . add ( selectedTheme ) ;
373+ } catch ( e ) { }
374+
371375 updateThemeSelected ( ) ;
372376 }
373377
Original file line number Diff line number Diff line change 8484 if (theme === null || theme === undefined ) { theme = default_theme; }
8585 var html = document .querySelector (' html' );
8686 html .classList .remove (' no-js' )
87- html .classList .remove (' {{ default_theme }}' )
88- html .classList .add (theme .replace (/ \W + / g , ' _' ).toLowerCase ());
87+ try {
88+ html .classList .remove (' {{ default_theme }}' );
89+ html .classList .add (theme .replace (/ \W + / g , ' _' ).toLowerCase ());
90+ } catch (e) { }
8991 html .classList .add (' js' );
9092 </script >
9193
You can’t perform that action at this time.
0 commit comments