Fixes memory leaks relating to events in IE with page unload and with jQuery methods remove, html and empty (#1610, #1618, #1697 and #1731). Also re-worked variable names to be more consistent with the core.
This commit is contained in:
parent
bb998f2518
commit
92aac3abd6
2 changed files with 47 additions and 37 deletions
15
src/core.js
15
src/core.js
|
@ -1251,17 +1251,20 @@ jQuery.each({
|
|||
|
||||
remove: function( selector ) {
|
||||
if ( !selector || jQuery.filter( selector, [ this ] ).r.length ) {
|
||||
jQuery.removeData( this );
|
||||
// Prevent memory leaks
|
||||
jQuery( "*", this ).add(this).each(function(){
|
||||
jQuery.event.remove(this);
|
||||
jQuery.removeData(this);
|
||||
});
|
||||
this.parentNode.removeChild( this );
|
||||
}
|
||||
},
|
||||
|
||||
empty: function() {
|
||||
// Clean up the cache
|
||||
jQuery( "*", this ).each(function(){
|
||||
jQuery.removeData(this);
|
||||
});
|
||||
|
||||
// Remove element nodes and prevent memory leaks
|
||||
jQuery( ">*", this ).remove();
|
||||
|
||||
// Remove any remaining nodes
|
||||
while ( this.firstChild )
|
||||
this.removeChild( this.firstChild );
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue