diff options
-rw-r--r-- | tests/unit/widget/widget_core.js | 7 | ||||
-rw-r--r-- | ui/jquery.ui.widget.js | 8 |
2 files changed, 14 insertions, 1 deletions
diff --git a/tests/unit/widget/widget_core.js b/tests/unit/widget/widget_core.js index 848579a1d..31f2b9ccf 100644 --- a/tests/unit/widget/widget_core.js +++ b/tests/unit/widget/widget_core.js @@ -1167,6 +1167,13 @@ test( "._trigger() - instance as element", function() { $( "#widget" ).testWidget().detach(); }); }); + + test( "destroy - remove event bubbling", function() { + shouldDestroy( false, function() { + $( "<div>child</div>" ).appendTo( $( "#widget" ).testWidget() ) + .trigger( "remove" ); + }); + }); }()); test( "redefine", function() { diff --git a/ui/jquery.ui.widget.js b/ui/jquery.ui.widget.js index 05487f7ed..ccbe0cac5 100644 --- a/ui/jquery.ui.widget.js +++ b/ui/jquery.ui.widget.js @@ -237,7 +237,13 @@ $.Widget.prototype = { // TODO remove dual storage $.data( element, this.widgetName, this ); $.data( element, this.widgetFullName, this ); - this._on({ remove: "destroy" }); + this._on({ + remove: function( event ) { + if ( event.target === element ) { + this.destroy(); + } + } + }); this.document = $( element.style ? // element within the document element.ownerDocument : |