Index: third_party/WebKit/Source/devtools/front_end/ui/SidebarPane.js |
diff --git a/third_party/WebKit/Source/devtools/front_end/ui/SidebarPane.js b/third_party/WebKit/Source/devtools/front_end/ui/SidebarPane.js |
index 956e687bb9bc931f0e35bf4538db8b641799683f..1284f671c52605d52907d14e5ebca76e73dec9d2 100644 |
--- a/third_party/WebKit/Source/devtools/front_end/ui/SidebarPane.js |
+++ b/third_party/WebKit/Source/devtools/front_end/ui/SidebarPane.js |
@@ -132,17 +132,22 @@ WebInspector.SidebarTabbedPane = function() |
this.element.classList.add("sidebar-pane-container", "sidebar-tabbed-pane"); |
} |
+WebInspector.SidebarTabbedPane._toolbarSymbol = Symbol("toolbar"); |
+ |
WebInspector.SidebarTabbedPane.prototype = { |
/** |
* @param {!WebInspector.View} pane |
*/ |
addPane: function(pane) |
{ |
- var title = pane.title(); |
+ // Detach first to trigger toolbar cleanup. |
+ pane.detach(); |
+ var title = pane.title(); |
var toolbarItems = pane.toolbarItems(); |
if (toolbarItems.length) { |
var toolbar = new WebInspector.Toolbar(""); |
+ pane[WebInspector.SidebarTabbedPane._toolbarSymbol] = toolbar; |
pane.element.insertBefore(toolbar.element, pane.element.firstChild); |
for (var item of toolbarItems) |
toolbar.appendToolbarItem(item); |
@@ -153,6 +158,19 @@ WebInspector.SidebarTabbedPane.prototype = { |
}, |
/** |
+ * @param {!WebInspector.Widget} widget |
+ * @override |
+ */ |
+ childWasDetached: function(widget) |
+ { |
+ WebInspector.TabbedPane.prototype.childWasDetached.call(this, widget); |
+ |
+ var toolbar = widget[WebInspector.SidebarTabbedPane._toolbarSymbol]; |
+ if (toolbar) |
+ toolbar.element.remove(); |
+ }, |
+ |
+ /** |
* @param {!WebInspector.View} pane |
* @param {boolean} visible |
*/ |