Skip to content

Commit 332fd94

Browse files
rwaldrongibson042
authored andcommitted
Data: restore explicit data removal of private data in cleanData.
Fixes gh-2127 Closes gh-2132
1 parent 9b03f6d commit 332fd94

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/manipulation.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ jQuery.extend({
305305
}
306306
}
307307
}
308-
delete data.events;
308+
delete elem[ dataPriv.expando ];
309309
}
310310
}
311311
}

test/unit/manipulation.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2047,6 +2047,23 @@ test( "jQuery.cleanData", function() {
20472047
}
20482048
});
20492049

2050+
test( "jQuery.cleanData eliminates all private data (gh-2127)", function() {
2051+
expect( 2 );
2052+
2053+
var div = jQuery( "<div/>" ).appendTo( "#qunit-fixture" );
2054+
2055+
jQuery._data( div[ 0 ], "gh-2127", "testing" );
2056+
2057+
ok( !jQuery.isEmptyObject( jQuery._data( div[ 0 ] ) ), "Ensure some private data exists" );
2058+
2059+
div.remove();
2060+
2061+
ok( jQuery.isEmptyObject( jQuery._data( div[ 0 ] ) ),
2062+
"Private data is empty after node is removed" );
2063+
2064+
div.remove();
2065+
});
2066+
20502067
test( "jQuery.buildFragment - no plain-text caching (Bug #6779)", function() {
20512068

20522069
expect( 1 );

0 commit comments

Comments
 (0)