@@ -223,18 +223,24 @@ document.querySelector("#version").textContent = _("Version",
223223 var currentPolicy = await UI . getPolicy ( cookieStoreId ) ;
224224
225225 function updateContainersEnabled ( ) {
226- let containersEnabled = Boolean ( contextStore . enabled && browser . contextualIdentities ) ;
226+ const containersEnabled = Boolean ( contextStore . enabled && browser . contextualIdentities ) ;
227227 document . querySelector ( "#containers-opt" ) . style . display = browser . contextualIdentities ? "" : "none" ;
228228 document . querySelector ( "#opt-containers" ) . disabled = ! browser . contextualIdentities ;
229229 document . querySelector ( "#opt-containers" ) . checked = contextStore . enabled ;
230- document . querySelector ( "#select-container" ) . hidden = ! containersEnabled ;
231- document . querySelector ( "#select-container-label" ) . hidden = ! containersEnabled ;
232- document . querySelector ( "#per-site-buttons" ) . style . display = containersEnabled ? "flex" : "none" ;
230+ document . querySelector ( "#container-options" ) . style . display = containersEnabled ? "" : "none" ;
233231 }
234232 updateContainersEnabled ( ) ;
235233
234+ function constrainContainerCopy ( ) {
235+ containerCopy . disabled = cookieStoreId == "default" ;
236+ for ( const opt of containerCopy . options ) {
237+ opt . disabled = opt . value == cookieStoreId ;
238+ }
239+ }
240+
236241 async function changeContainer ( ) {
237242 cookieStoreId = containerSelect . value ;
243+ constrainContainerCopy ( ) ;
238244 currentPolicy = await UI . getPolicy ( cookieStoreId ) ;
239245 debug ( "container change" , cookieStoreId , currentPolicy ) ;
240246 sitesUI . clear ( )
@@ -275,13 +281,24 @@ document.querySelector("#version").textContent = _("Version",
275281 }
276282 if ( JSON . stringify ( newContainers ) == JSON . stringify ( containers ) ) return ;
277283 containers = newContainers ;
278- var container_options = ""
279- for ( var container of containers ) {
280- container_options += "<option value=" + container . cookieStoreId + ">" + container . name + "</option>"
284+ const options = document . createDocumentFragment ( ) ;
285+ for ( const container of containers ) {
286+ const o = options . appendChild ( document . createElement ( "option" ) ) ;
287+ o . value = container . cookieStoreId ;
288+ o . text = container . name ;
281289 }
282- containerSelect . innerHTML = container_options ;
290+ while ( containerSelect . firstChild ) {
291+ containerSelect . removeChild ( containerSelect . firstChild ) ;
292+ }
293+ containerSelect . appendChild ( options . cloneNode ( true ) ) ;
283294 containerSelect . value = cookieStoreId ;
284- containerCopy . innerHTML = "<option value=blank></option>" + container_options ;
295+ while ( containerCopy . firstChild ) {
296+ containerCopy . removeChild ( containerCopy . firstChild ) ;
297+ }
298+ containerCopy . appendChild ( document . createElement ( "option" ) ) . value = "blank" ;
299+ containerCopy . appendChild ( options ) ;
300+
301+ constrainContainerCopy ( ) ;
285302 }
286303 containerSelect . onfocus = updateContainerOptions ;
287304 containerCopy . onfocus = updateContainerOptions ;
0 commit comments