File tree Expand file tree Collapse file tree 1 file changed +13
-7
lines changed Expand file tree Collapse file tree 1 file changed +13
-7
lines changed Original file line number Diff line number Diff line change @@ -285,7 +285,7 @@ function playpen_text(playpen) {
285285 function showThemes ( ) {
286286 themePopup . style . display = 'block' ;
287287 themeToggleButton . setAttribute ( 'aria-expanded' , true ) ;
288- themePopup . querySelector ( "button#" + document . body . className ) . focus ( ) ;
288+ themePopup . querySelector ( "button#" + get_theme ( ) ) . focus ( ) ;
289289 }
290290
291291 function hideThemes ( ) {
@@ -294,6 +294,16 @@ function playpen_text(playpen) {
294294 themeToggleButton . focus ( ) ;
295295 }
296296
297+ function get_theme ( ) {
298+ var theme ;
299+ try { theme = localStorage . getItem ( 'mdbook-theme' ) ; } catch ( e ) { }
300+ if ( theme === null || theme === undefined ) {
301+ return default_theme ;
302+ } else {
303+ return theme ;
304+ }
305+ }
306+
297307 function set_theme ( theme , store = true ) {
298308 let ace_theme ;
299309
@@ -325,9 +335,7 @@ function playpen_text(playpen) {
325335 } ) ;
326336 }
327337
328- var previousTheme ;
329- try { previousTheme = localStorage . getItem ( 'mdbook-theme' ) ; } catch ( e ) { }
330- if ( previousTheme === null || previousTheme === undefined ) { previousTheme = default_theme ; }
338+ var previousTheme = get_theme ( ) ;
331339
332340 if ( store ) {
333341 try { localStorage . setItem ( 'mdbook-theme' , theme ) ; } catch ( e ) { }
@@ -338,9 +346,7 @@ function playpen_text(playpen) {
338346 }
339347
340348 // Set theme
341- var theme ;
342- try { theme = localStorage . getItem ( 'mdbook-theme' ) ; } catch ( e ) { }
343- if ( theme === null || theme === undefined ) { theme = default_theme ; }
349+ var theme = get_theme ( ) ;
344350
345351 set_theme ( theme , false ) ;
346352
You can’t perform that action at this time.
0 commit comments