// Attempt to get data from the cache
// with the key as-is
- data = dataUser.get( elem, key );
+ data = dataUser.get( elem, key ) ||
+
+ // Try to find dashed key if it exists (gh-2779)
+ // This is for 2.2.x only
+ dataUser.get( elem, key.replace( rmultiDash, "-$&" ).toLowerCase() );
+
if ( data !== undefined ) {
return data;
}
}
}
} );
+
+QUnit.test( ".data(camelCase) retrieves hyphenated keys", function( assert ) {
+ assert.expect( 1 );
+
+ var div = jQuery( "<div/>" );
+
+ $.data( div[ 0 ], "data-test", "data" );
+ assert.equal( div.data( "dataTest" ), "data" );
+} );