return cache;
},
get: function( owner, key ) {
- var cache = this.cache( owner );
-
return key === undefined ?
- cache :
+ this.cache( owner ) :
// Always use camelCase key (gh-2257)
- cache[ jQuery.camelCase( key ) ];
+ owner[ this.expando ] && owner[ this.expando ][ jQuery.camelCase( key ) ];
},
access: function( owner, key, value ) {
}
}
} );
+
+QUnit.test( ".data(prop) does not create expando", function( assert ) {
+ assert.expect( 1 );
+
+ var key,
+ div = jQuery( "<div/>" );
+
+ div.data("foo");
+ assert.equal( false, jQuery.hasData( div[0] ) );
+ // Make sure no expando has been added
+ for ( key in div[ 0 ] ) {
+ if ( /^jQuery/.test( key ) ) {
+ assert.ok( false, "Expando was created on access" );
+ }
+ }
+} );