]> source.dussan.org Git - jquery-ui.git/commitdiff
Widget: Fixed a problem with the .remove() proxy.
authorScott González <scott.gonzalez@gmail.com>
Sat, 6 Feb 2010 02:12:41 +0000 (02:12 +0000)
committerScott González <scott.gonzalez@gmail.com>
Sat, 6 Feb 2010 02:12:41 +0000 (02:12 +0000)
Fixes #5143 - .remove() proxy doesn't work properly.

ui/jquery.ui.widget.js

index 29d09794cf46bd20139cc4942858da1eabd5d913..49067449dcdc083a52ef5dd015e32517a3a86881 100644 (file)
 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 ) {