-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Commit
…08 - Widget: auto-destroy is broken in jQuery 1.4.
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,20 +9,30 @@ | |
*/ | ||
(function( $, undefined ) { | ||
|
||
var _remove = $.fn.remove; | ||
|
||
$.fn.remove = function( selector, keepData ) { | ||
return this.each(function() { | ||
if ( !keepData ) { | ||
if ( !selector || $.filter( selector, [ this ] ).length ) { | ||
$( "*", this ).add( [ this ] ).each(function() { | ||
$( this ).triggerHandler( "remove" ); | ||
}); | ||
} | ||
// jQuery 1.4+ | ||
if ( $.cleanData ) { | ||
var _cleanData = $.cleanData; | ||
$.cleanData = function( elems ) { | ||
for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) { | ||
$( elem ).triggerHandler( "remove" ); | ||
} | ||
return _remove.call( $(this), selector, keepData ); | ||
}); | ||
}; | ||
_cleanData( elems ); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
scottgonzalez
Author
Member
|
||
}; | ||
} else { | ||
var _remove = $.fn.remove; | ||
$.fn.remove = function( selector, keepData ) { | ||
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 ) { | ||
var namespace = name.split( "." )[ 0 ], | ||
|
2 comments
on commit 0a0a39f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why destroy widgets on detach?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't, the test makes sure that destroy isn't called on .detach().
There's an additional (internal) argument 'acceptData' in jQuery.cleanData - why's that not passed here?
(seems to be a perf.opt. as it just prevents some duplicate calls to jQuery.acceptData)