aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc-Andre Lafortune <github@marc-andre.ca>2012-10-07 02:35:01 -0400
committerScott González <scott.gonzalez@gmail.com>2012-10-23 14:06:30 -0400
commit8bb05d23e2c49ecbe2f83a3552efb0a93c48bb85 (patch)
treeda81b6f0550a347b6f38afb56f1e9cb0d86b9da6
parentb1b07e8046aa0f0b543ade96eb28567af68efb81 (diff)
downloadjquery-ui-8bb05d23e2c49ecbe2f83a3552efb0a93c48bb85.tar.gz
jquery-ui-8bb05d23e2c49ecbe2f83a3552efb0a93c48bb85.zip
Widget: Destroy only when element is the actual target. Fixes #8652 - Widget: Destroy only when element is the actual target.
-rw-r--r--tests/unit/widget/widget_core.js7
-rw-r--r--ui/jquery.ui.widget.js8
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 :