Bug 1407435 - After animating out from the toolbar, the widget no longer remains invisible. r=jaws
authorErica Wright <ewright@mozilla.com>
Wed, 11 Oct 2017 15:12:21 -0400
changeset 679136 462c85ecfe5b684a34b1b133995dc5d2e97ae10e
parent 679135 28a041a33fece4b42d3984cca4698334d656c99e
child 679137 ca60b3cab4ed50a6f4c06ac0bb9498aaedd9551b
push id84141
push userbmo:schien@mozilla.com
push dateThu, 12 Oct 2017 11:13:04 +0000
reviewersjaws
bugs1407435
milestone58.0a1
Bug 1407435 - After animating out from the toolbar, the widget no longer remains invisible. r=jaws MozReview-Commit-ID: 5WmcIFWqBYi
browser/components/customizableui/CustomizeMode.jsm
--- a/browser/components/customizableui/CustomizeMode.jsm
+++ b/browser/components/customizableui/CustomizeMode.jsm
@@ -583,17 +583,17 @@ CustomizeMode.prototype = {
   _promiseWidgetAnimationOut(aNode) {
     if (!gCosmeticAnimationsEnabled ||
         aNode.getAttribute("cui-anchorid") == "nav-bar-overflow-button" ||
         (aNode.tagName != "toolbaritem" && aNode.tagName != "toolbarbutton") ||
         (aNode.id == "downloads-button" && aNode.hidden)) {
       return null;
     }
     let animationNode;
-    if (aNode.parentNode.id.startsWith("wrapper-")) {
+    if (aNode.parentNode && aNode.parentNode.id.startsWith("wrapper-")) {
       animationNode = aNode.parentNode;
     } else {
       animationNode = aNode;
     }
     return new Promise(resolve => {
       animationNode.classList.add("animate-out");
       animationNode.addEventListener("animationend", function cleanupWidgetAnimationEnd(e) {
         if (e.animationName == "widget-animate-out" && e.target.id == animationNode.id) {
@@ -628,17 +628,17 @@ CustomizeMode.prototype = {
     if (aNode.id == "downloads-button") {
       Services.prefs.setBoolPref(kDownloadAutoHidePref, false);
       if (this._customizing) {
         this._showDownloadsAutoHidePanel();
       }
     }
 
     if (widgetAnimationPromise) {
-      if (aNode.parentNode.id.startsWith("wrapper-")) {
+      if (aNode.parentNode && aNode.parentNode.id.startsWith("wrapper-")) {
         aNode.parentNode.classList.remove("animate-out");
       } else {
         aNode.classList.remove("animate-out")
       }
     }
   },
 
   async addToPanel(aNode) {
@@ -661,17 +661,17 @@ CustomizeMode.prototype = {
     if (aNode.id == "downloads-button") {
       Services.prefs.setBoolPref(kDownloadAutoHidePref, false);
       if (this._customizing) {
         this._showDownloadsAutoHidePanel();
       }
     }
 
     if (widgetAnimationPromise) {
-      if (aNode.parentNode.id.startsWith("wrapper-")) {
+      if (aNode.parentNode && aNode.parentNode.id.startsWith("wrapper-")) {
         aNode.parentNode.classList.remove("animate-out");
       } else {
         aNode.classList.remove("animate-out")
       }
     }
     if (gCosmeticAnimationsEnabled) {
       let overflowButton = this.document.getElementById("nav-bar-overflow-button");
       BrowserUtils.setToolbarButtonHeightProperty(overflowButton).then(() => {
@@ -707,17 +707,17 @@ CustomizeMode.prototype = {
     // If the user explicitly removes this item, turn off autohide.
     if (aNode.id == "downloads-button") {
       Services.prefs.setBoolPref(kDownloadAutoHidePref, false);
       if (this._customizing) {
         this._showDownloadsAutoHidePanel();
       }
     }
     if (widgetAnimationPromise) {
-      if (aNode.parentNode.id.startsWith("wrapper-")) {
+      if (aNode.parentNode && aNode.parentNode.id.startsWith("wrapper-")) {
         aNode.parentNode.classList.remove("animate-out");
       } else {
         aNode.classList.remove("animate-out")
       }
     }
   },
 
   populatePalette() {