git.asbjorn.biz
/
jquery.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fixes memory leaks relating to events in IE with page unload and with jQuery methods...
[jquery.git]
/
src
/
core.js
diff --git
a/src/core.js
b/src/core.js
index
59cc1fc
..
3cfabe3
100644
(file)
--- a/
src/core.js
+++ b/
src/core.js
@@
-1251,17
+1251,20
@@
jQuery.each({
remove: function( selector ) {
if ( !selector || jQuery.filter( selector, [ this ] ).r.length ) {
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() {
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 );
}
while ( this.firstChild )
this.removeChild( this.firstChild );
}