Bug 1628911 - Remove, preserve and reinstate more attributes that can mess up the appearance of customizeToolbar dialog r=mkmelin
authorIan Neal <iann_cvs@blueyonder.co.uk>
Fri, 10 Apr 2020 00:26:19 +0100
changeset 37908 b918ea799c2e29c78fa3449c32dd0bde6fb643ed
parent 37907 811d59aed80df519cc061a177e48810a29dc2c7b
child 37909 3758d7aac18138b7638a47a3d5295eca86daad08
push id2595
push userclokep@gmail.com
push dateMon, 04 May 2020 19:02:04 +0000
treeherdercomm-beta@f53913797371 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmkmelin
bugs1628911
Bug 1628911 - Remove, preserve and reinstate more attributes that can mess up the appearance of customizeToolbar dialog r=mkmelin
common/src/customizeToolbar.js
--- a/common/src/customizeToolbar.js
+++ b/common/src/customizeToolbar.js
@@ -350,16 +350,18 @@ function cleanUpItemForPalette(aItem, aW
   }
   aWrapper.setAttribute("tooltiptext", aWrapper.getAttribute("title"));
 
   // Remove attributes that screw up our appearance.
   aItem.removeAttribute("command");
   aItem.removeAttribute("observes");
   aItem.removeAttribute("type");
   aItem.removeAttribute("width");
+  aItem.removeAttribute("checked");
+  aItem.removeAttribute("collapsed");
 
   aWrapper.querySelectorAll("[disabled]").forEach(function(aNode) {
     aNode.removeAttribute("disabled");
   });
 }
 
 /**
  * Makes sure that an item that has been cloned from a template
@@ -371,16 +373,21 @@ function cleanupItemForToolbar(aItem, aW
   setWrapperType(aItem, aWrapper);
   aWrapper.setAttribute("place", "toolbar");
 
   if (aItem.hasAttribute("command")) {
     aWrapper.setAttribute("itemcommand", aItem.getAttribute("command"));
     aItem.removeAttribute("command");
   }
 
+  if (aItem.hasAttribute("collapsed")) {
+    aWrapper.setAttribute("itemcollapsed", aItem.getAttribute("collapsed"));
+    aItem.removeAttribute("collapsed");
+  }
+
   if (aItem.checked) {
     aWrapper.setAttribute("itemchecked", "true");
     aItem.checked = false;
   }
 
   if (aItem.disabled) {
     aWrapper.setAttribute("itemdisabled", "true");
     aItem.disabled = false;
@@ -394,16 +401,21 @@ function restoreItemForToolbar(aItem, aW
   if (aWrapper.hasAttribute("itemdisabled")) {
     aItem.disabled = true;
   }
 
   if (aWrapper.hasAttribute("itemchecked")) {
     aItem.checked = true;
   }
 
+  if (aWrapper.hasAttribute("itemcollapsed")) {
+    let collapsed = aWrapper.getAttribute("itemcollapsed");
+    aItem.setAttribute("collapsed", collapsed);
+  }
+
   if (aWrapper.hasAttribute("itemcommand")) {
     let commandID = aWrapper.getAttribute("itemcommand");
     aItem.setAttribute("command", commandID);
 
     // XXX Bug 309953 - toolbarbuttons aren't in sync with their commands after customizing
     let command = gToolboxDocument.getElementById(commandID);
     if (command && command.hasAttribute("disabled")) {
       aItem.setAttribute("disabled", command.getAttribute("disabled"));