Bug 1407435 - After animating out from the toolbar, the widget no longer remains invisible. r?jaws draft
authorErica Wright <ewright@mozilla.com>
Wed, 11 Oct 2017 15:12:21 -0400
changeset 678667 fec7e0059362a0b68c6bea4b71241f7cc1891144
parent 678653 5cc87630fff42a8cb272ec58c530ef68007ecacd
child 735405 2496c0d0d5e807254990523d3cddcf63bd219ff4
push id84006
push userbmo:ewright@mozilla.com
push dateWed, 11 Oct 2017 19:12:37 +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() {