Skip to content

Commit

Permalink
Widget: Destroy only when element is the actual target. Fixes #8652 -…
Browse files Browse the repository at this point in the history
… Widget: Destroy only when element is the actual target.
  • Loading branch information
marcandre authored and scottgonzalez committed Oct 23, 2012
1 parent b1b07e8 commit 8bb05d2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
7 changes: 7 additions & 0 deletions tests/unit/widget/widget_core.js
Expand Up @@ -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() {
Expand Down
8 changes: 7 additions & 1 deletion ui/jquery.ui.widget.js
Expand Up @@ -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 :
Expand Down

6 comments on commit 8bb05d2

@jzaefferer
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@marcandre Marc, could you sign our CLA? http://jquery.github.com/cla.html Thanks.

@marcandre
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Already did a month ago (#736 (comment) )

@jzaefferer
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I looked for "Marc-Andre Lafortune" (and parts of that) and can't find you in our list. @scottgonzalez am I missing something?

@scottgonzalez
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That sure is strange. I'm sure I would've waited for the CLA to come through, and Marc seems to remember signing it, but I don't see it in the list. @marcandre Would you mind signing it again? I'm not sure why the previous submission isn't showing up for us.

@marcandre
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@scottgonzalez
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Sorry about the need to sign twice.

Please sign in to comment.