mirror of
https://github.com/jquery/jquery-ui.git
synced 2025-01-07 20:34:24 +00:00
Widget: Destroy only when element is the actual target. Fixes #8652 - Widget: Destroy only when element is the actual target.
This commit is contained in:
parent
b1b07e8046
commit
8bb05d23e2
@ -1167,6 +1167,13 @@ test( "._trigger() - instance as element", function() {
|
|||||||
$( "#widget" ).testWidget().detach();
|
$( "#widget" ).testWidget().detach();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test( "destroy - remove event bubbling", function() {
|
||||||
|
shouldDestroy( false, function() {
|
||||||
|
$( "<div>child</div>" ).appendTo( $( "#widget" ).testWidget() )
|
||||||
|
.trigger( "remove" );
|
||||||
|
});
|
||||||
|
});
|
||||||
}());
|
}());
|
||||||
|
|
||||||
test( "redefine", function() {
|
test( "redefine", function() {
|
||||||
|
8
ui/jquery.ui.widget.js
vendored
8
ui/jquery.ui.widget.js
vendored
@ -237,7 +237,13 @@ $.Widget.prototype = {
|
|||||||
// TODO remove dual storage
|
// TODO remove dual storage
|
||||||
$.data( element, this.widgetName, this );
|
$.data( element, this.widgetName, this );
|
||||||
$.data( element, this.widgetFullName, 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 ?
|
this.document = $( element.style ?
|
||||||
// element within the document
|
// element within the document
|
||||||
element.ownerDocument :
|
element.ownerDocument :
|
||||||
|
Loading…
Reference in New Issue
Block a user