@@ -19,18 +19,18 @@ const _CURRENT_PREFIX = (() => {
19
19
return window . location . pathname . split ( '/' , _NUM_PREFIX_PARTS ) . join ( '/' ) + '/' ;
20
20
} ) ( ) ;
21
21
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 ) ) ;
24
24
25
- const _create_version_select = ( ) => {
25
+ const _create_version_select = ( versions ) => {
26
26
const select = document . createElement ( 'select' ) ;
27
27
select . className = 'version-select' ;
28
28
if ( _IS_LOCAL ) {
29
29
select . disabled = true ;
30
30
select . title = 'Version switching is disabled in local builds' ;
31
31
}
32
32
33
- for ( const [ version , title ] of Object . entries ( all_versions ) ) {
33
+ for ( const [ version , title ] of versions ) {
34
34
const option = document . createElement ( 'option' ) ;
35
35
option . value = version ;
36
36
if ( version === _CURRENT_VERSION ) {
@@ -45,10 +45,10 @@ const _create_version_select = () => {
45
45
return select ;
46
46
} ;
47
47
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 ) ;
52
52
}
53
53
54
54
const select = document . createElement ( 'select' ) ;
@@ -58,7 +58,7 @@ const _create_language_select = () => {
58
58
select . title = 'Language switching is disabled in local builds' ;
59
59
}
60
60
61
- for ( const [ language , title ] of Object . entries ( all_languages ) ) {
61
+ for ( const [ language , title ] of languages ) {
62
62
const option = document . createElement ( 'option' ) ;
63
63
option . value = language ;
64
64
option . text = title ;
@@ -136,7 +136,10 @@ const _on_language_switch = (event) => {
136
136
} ;
137
137
138
138
const _initialise_switchers = ( ) => {
139
- const version_select = _create_version_select ( ) ;
139
+ const versions = _ALL_VERSIONS ;
140
+ const languages = _ALL_LANGUAGES ;
141
+
142
+ const version_select = _create_version_select ( versions ) ;
140
143
document
141
144
. querySelectorAll ( '.version_switcher_placeholder' )
142
145
. forEach ( ( placeholder ) => {
@@ -146,7 +149,7 @@ const _initialise_switchers = () => {
146
149
placeholder . classList . remove ( 'version_switcher_placeholder' ) ;
147
150
} ) ;
148
151
149
- const language_select = _create_language_select ( ) ;
152
+ const language_select = _create_language_select ( languages ) ;
150
153
document
151
154
. querySelectorAll ( '.language_switcher_placeholder' )
152
155
. forEach ( ( placeholder ) => {
0 commit comments