aboutsummaryrefslogtreecommitdiffstats
path: root/src/manipulation.js
diff options
context:
space:
mode:
authorjeresig <jeresig@gmail.com>2010-01-23 21:20:19 -0500
committerjeresig <jeresig@gmail.com>2010-01-23 21:20:19 -0500
commitf06e0e5575bc8f82d0fcbd5880bb9d8ccf361bfa (patch)
tree58277776649fba1be4e3a54ee1602d043cb1b4b0 /src/manipulation.js
parent4f9aa62a858f28b8ed310ac73f9d2cd788bf1eed (diff)
downloadjquery-f06e0e5575bc8f82d0fcbd5880bb9d8ccf361bfa.tar.gz
jquery-f06e0e5575bc8f82d0fcbd5880bb9d8ccf361bfa.zip
Expose cleanData, make sure that all bound event handlers are properly cleaned up after html/empty/remove. Fixes #5856 and #5906.
Diffstat (limited to 'src/manipulation.js')
-rw-r--r--src/manipulation.js23
1 files changed, 11 insertions, 12 deletions
diff --git a/src/manipulation.js b/src/manipulation.js
index 59edcbcef..401cf86bd 100644
--- a/src/manipulation.js
+++ b/src/manipulation.js
@@ -193,7 +193,7 @@ jQuery.fn.extend({
for ( var i = 0, l = this.length; i < l; i++ ) {
// Remove element nodes and prevent memory leaks
if ( this[i].nodeType === 1 ) {
- cleanData( this[i].getElementsByTagName("*") );
+ jQuery.cleanData( this[i].getElementsByTagName("*") );
this[i].innerHTML = value;
}
}
@@ -373,8 +373,8 @@ jQuery.each({
remove: function( selector, keepData ) {
if ( !selector || jQuery.filter( selector, [ this ] ).length ) {
if ( !keepData && this.nodeType === 1 ) {
- cleanData( this.getElementsByTagName("*") );
- cleanData( [ this ] );
+ jQuery.cleanData( this.getElementsByTagName("*") );
+ jQuery.cleanData( [ this ] );
}
if ( this.parentNode ) {
@@ -386,7 +386,7 @@ jQuery.each({
empty: function() {
// Remove element nodes and prevent memory leaks
if ( this.nodeType === 1 ) {
- cleanData( this.getElementsByTagName("*") );
+ jQuery.cleanData( this.getElementsByTagName("*") );
}
// Remove any remaining nodes
@@ -493,13 +493,12 @@ jQuery.extend({
}
return ret;
- }
-});
-
-function cleanData( elems ) {
- for ( var i = 0, elem, id; (elem = elems[i]) != null; i++ ) {
- if ( !jQuery.noData[elem.nodeName.toLowerCase()] && (id = elem[expando]) ) {
- delete jQuery.cache[ id ];
+ },
+
+ cleanData: function( elems ) {
+ for ( var i = 0, elem, id; (elem = elems[i]) != null; i++ ) {
+ jQuery.event.remove( elem );
+ jQuery.removeData( elem );
}
}
-}
+}); \ No newline at end of file