diff --git a/tests/unit/widget/widget_core.js b/tests/unit/widget/widget_core.js index 9180072e3..1c8589841 100644 --- a/tests/unit/widget/widget_core.js +++ b/tests/unit/widget/widget_core.js @@ -1203,6 +1203,12 @@ test( "._trigger() - instance as element", function() { }); }); + test( "auto-destroy - .remove() when disabled", function() { + shouldDestroy( true, function() { + $( "#widget" ).testWidget({ disabled: true }).remove(); + }); + }); + test( "auto-destroy - .remove() on parent", function() { shouldDestroy( true, function() { $( "#widget" ).testWidget().parent().remove(); diff --git a/ui/jquery.ui.widget.js b/ui/jquery.ui.widget.js index 0ad634dfd..333212f0a 100644 --- a/ui/jquery.ui.widget.js +++ b/ui/jquery.ui.widget.js @@ -237,7 +237,7 @@ $.Widget.prototype = { // TODO remove dual storage $.data( element, this.widgetName, this ); $.data( element, this.widgetFullName, this ); - this._on( this.element, { + this._on( true, this.element, { remove: function( event ) { if ( event.target === element ) { this.destroy();