diff --git a/browser/components/customizableui/CustomizableUI.jsm b/browser/components/customizableui/CustomizableUI.jsm index afd6122c213d..fa72f40efaa2 100644 --- a/browser/components/customizableui/CustomizableUI.jsm +++ b/browser/components/customizableui/CustomizableUI.jsm @@ -2336,6 +2336,7 @@ var CustomizableUIInternal = { this.wrapWidgetEventHandler("onBeforeCreated", widget); this.wrapWidgetEventHandler("onClick", widget); this.wrapWidgetEventHandler("onCreated", widget); + this.wrapWidgetEventHandler("onDestroyed", widget); if (widget.type == "button") { widget.onCommand = typeof aData.onCommand == "function" ? @@ -2439,6 +2440,9 @@ var CustomizableUIInternal = { } } } + if (widgetNode && widget.onDestroyed) { + widget.onDestroyed(window.document); + } } gPalette.delete(aWidgetId); @@ -3172,6 +3176,11 @@ this.CustomizableUI = { * - onCreated(aNode): Attached to all widgets; a function that will be invoked * whenever the widget has a DOM node constructed, passing the * constructed node as an argument. + * - onDestroyed(aDoc): Attached to all non-custom widgets; a function that + * will be invoked after the widget has a DOM node destroyed, + * passing the document from which it was removed. This is + * useful especially for 'view' type widgets that need to + * cleanup after views that were constructed on the fly. * - onCommand(aEvt): Only useful for button widgets; a function that will be * invoked when the user activates the button. * - onClick(aEvt): Attached to all widgets; a function that will be invoked