@@ -19,18 +19,18 @@ const _CURRENT_PREFIX = (() => {
1919 return window . location . pathname . split ( '/' , _NUM_PREFIX_PARTS ) . join ( '/' ) + '/' ;
2020} ) ( ) ;
2121
22- const all_versions = $VERSIONS ;
23- const all_languages = $LANGUAGES ;
22+ const _ALL_VERSIONS = new Map ( Object . entries ( $VERSIONS ) ) ;
23+ const _ALL_LANGUAGES = new Map ( Object . entries ( $LANGUAGES ) ) ;
2424
25- const _create_version_select = ( ) => {
25+ const _create_version_select = ( versions ) => {
2626 const select = document . createElement ( 'select' ) ;
2727 select . className = 'version-select' ;
2828 if ( _IS_LOCAL ) {
2929 select . disabled = true ;
3030 select . title = 'Version switching is disabled in local builds' ;
3131 }
3232
33- for ( const [ version , title ] of Object . entries ( all_versions ) ) {
33+ for ( const [ version , title ] of versions ) {
3434 const option = document . createElement ( 'option' ) ;
3535 option . value = version ;
3636 if ( version === _CURRENT_VERSION ) {
@@ -45,10 +45,10 @@ const _create_version_select = () => {
4545 return select ;
4646} ;
4747
48- const _create_language_select = ( ) => {
49- if ( ! ( _CURRENT_LANGUAGE in all_languages ) ) {
50- // In case we are browsing a language that is not yet in all_languages .
51- all_languages [ _CURRENT_LANGUAGE ] = _CURRENT_LANGUAGE ;
48+ const _create_language_select = ( languages ) => {
49+ if ( ! languages . has ( _CURRENT_LANGUAGE ) ) {
50+ // In case we are browsing a language that is not yet in languages .
51+ languages . set ( _CURRENT_LANGUAGE , _CURRENT_LANGUAGE ) ;
5252 }
5353
5454 const select = document . createElement ( 'select' ) ;
@@ -58,7 +58,7 @@ const _create_language_select = () => {
5858 select . title = 'Language switching is disabled in local builds' ;
5959 }
6060
61- for ( const [ language , title ] of Object . entries ( all_languages ) ) {
61+ for ( const [ language , title ] of languages ) {
6262 const option = document . createElement ( 'option' ) ;
6363 option . value = language ;
6464 option . text = title ;
@@ -131,7 +131,10 @@ const _on_language_switch = (event) => {
131131} ;
132132
133133const _initialise_switchers = ( ) => {
134- const version_select = _create_version_select ( ) ;
134+ const versions = _ALL_VERSIONS ;
135+ const languages = _ALL_LANGUAGES ;
136+
137+ const version_select = _create_version_select ( versions ) ;
135138 document
136139 . querySelectorAll ( '.version_switcher_placeholder' )
137140 . forEach ( ( placeholder ) => {
@@ -141,7 +144,7 @@ const _initialise_switchers = () => {
141144 placeholder . classList . remove ( 'version_switcher_placeholder' ) ;
142145 } ) ;
143146
144- const language_select = _create_language_select ( ) ;
147+ const language_select = _create_language_select ( languages ) ;
145148 document
146149 . querySelectorAll ( '.language_switcher_placeholder' )
147150 . forEach ( ( placeholder ) => {
0 commit comments