Data: remove the expando when there's no more data

Fixes gh-1760
Close gh-2271
This commit is contained in:
Timmy Willison
2015-05-06 15:29:06 -07:00
parent 764dc949d0
commit 56bb677725
4 changed files with 48 additions and 13 deletions

View File

@@ -120,10 +120,7 @@ Data.prototype = {
return;
}
if ( key === undefined ) {
this.register( owner );
} else {
if ( key !== undefined ) {
// Support array or space separated string of keys
if ( jQuery.isArray( key ) ) {
@@ -147,6 +144,11 @@ Data.prototype = {
delete cache[ key[ i ] ];
}
}
// Remove the expando if there's no more data
if ( key === undefined || jQuery.isEmptyObject( cache ) ) {
delete owner[ this.expando ];
}
},
hasData: function( owner ) {
var cache = owner[ this.expando ];