File tree 2 files changed +11
-5
lines changed
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) {
361
361
} ) ;
362
362
}
363
363
364
- var previousTheme = get_theme ( ) ;
364
+ var previousTheme = get_theme ( ) . replace ( / \W + / g, '_' ) . toLowerCase ( ) ;
365
+ var selectedTheme = theme . replace ( / \W + / g, '_' ) . toLowerCase ( ) ;
365
366
if ( store ) {
366
367
try { localStorage . setItem ( 'mdbook-theme' , theme ) ; } catch ( e ) { }
367
368
}
368
369
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
+
371
375
updateThemeSelected ( ) ;
372
376
}
373
377
Original file line number Diff line number Diff line change 84
84
if (theme === null || theme === undefined ) { theme = default_theme; }
85
85
var html = document .querySelector (' html' );
86
86
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) { }
89
91
html .classList .add (' js' );
90
92
</script >
91
93
You can’t perform that action at this time.
0 commit comments