Bug 1441284 - Part 4 - Remove redundant calls before _moveOutKids and simplify the function. r=Gijs
The main view is already included in the children of the view stack, so the code that moves it out separately can be removed. The "mainview" attribute is already set to the correct value the next time the view is opened.
MozReview-Commit-ID: B8LMAxWvvTb
--- a/browser/components/customizableui/PanelMultiView.jsm
+++ b/browser/components/customizableui/PanelMultiView.jsm
@@ -438,24 +438,18 @@ var PanelMultiView = class extends this.
}
disconnect() {
// Guard against re-entrancy.
if (!this.node || !this.connected)
return;
this._cleanupTransitionPhase();
- let mainView = this._mainView;
- if (mainView) {
- if (this._panelViewCache)
- this._panelViewCache.appendChild(mainView);
- mainView.removeAttribute("mainview");
- }
- this._moveOutKids(this._viewStack);
+ this._moveOutKids();
this._panel.removeEventListener("mousemove", this);
this._panel.removeEventListener("popupshowing", this);
this._panel.removeEventListener("popuppositioned", this);
this._panel.removeEventListener("popupshown", this);
this._panel.removeEventListener("popuphidden", this);
this.window.removeEventListener("keydown", this);
this.node = this._openPopupPromise = this._openPopupCancelCallback =
this._viewContainer = this._viewStack = this.__dwu =
@@ -596,29 +590,26 @@ var PanelMultiView = class extends this.
// call this function, but the second time openViews will be empty.
this.closeAllViews();
}
/**
* Remove any child subviews into the panelViewCache, to ensure
* they remain usable even if this panelmultiview instance is removed
* from the DOM.
- * @param viewNodeContainer the container from which to remove subviews
*/
- _moveOutKids(viewNodeContainer) {
+ _moveOutKids() {
if (!this._panelViewCache)
return;
// Node.children and Node.childNodes is live to DOM changes like the
// ones we're about to do, so iterate over a static copy:
- let subviews = Array.from(viewNodeContainer.childNodes);
+ let subviews = Array.from(this._viewStack.childNodes);
for (let subview of subviews) {
- // XBL lists the 'children' XBL element explicitly. :-(
- if (subview.nodeName != "children")
- this._panelViewCache.appendChild(subview);
+ this._panelViewCache.appendChild(subview);
}
}
/**
* Slides in the specified view as a subview.
*
* @param viewIdOrNode
* DOM element or string ID of the <panelview> to display.