From: Scott González Date: Sat, 6 Feb 2010 02:12:41 +0000 (+0000) Subject: Widget: Fixed a problem with the .remove() proxy. X-Git-Tag: 1.8rc2~20 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=f775b00cfa0ad662dd0e5215c9a61a210181a8d1;p=jquery-ui.git Widget: Fixed a problem with the .remove() proxy. Fixes #5143 - .remove() proxy doesn't work properly. --- diff --git a/ui/jquery.ui.widget.js b/ui/jquery.ui.widget.js index 29d09794c..49067449d 100644 --- a/ui/jquery.ui.widget.js +++ b/ui/jquery.ui.widget.js @@ -12,12 +12,16 @@ var _remove = $.fn.remove; $.fn.remove = function( selector, keepData ) { - if ( !keepData ) { - $( "*", this ).add( this ).each(function() { - $( this ).triggerHandler( "remove" ); - }); - } - return _remove.apply( this, arguments ); + return this.each(function() { + if ( !keepData ) { + if ( !selector || $.filter( selector, [ this ] ).length ) { + $( "*", this ).add( this ).each(function() { + $( this ).triggerHandler( "remove" ); + }); + } + } + return _remove.call( $(this), selector, keepData ); + }); }; $.widget = function( name, base, prototype ) {