Skip to content

Commit

Permalink
Data: camelCasing should not ignore case
Browse files Browse the repository at this point in the history
Fixes gh-2070
  • Loading branch information
timmywil committed May 4, 2015
1 parent 0e79098 commit 172cad8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ var

// Matches dashed string for camelizing
rmsPrefix = /^-ms-/,
rdashAlpha = /-([a-z])/gi,
rdashAlpha = /-([a-z])/g,

// Used by jQuery.camelCase as callback to replace()
fcamelCase = function( all, letter ) {
Expand Down
10 changes: 10 additions & 0 deletions test/unit/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,16 @@ test(".data always sets data with the camelCased key (gh-2257)", function() {
});
});

test( ".data should not strip more than one hyphen when camelCasing (gh-2070)", function() {
expect( 3 );
var div = jQuery( "<div data-nested-single='single' data-nested--double='double' data-nested---triple='triple'></div>" ).appendTo( "#qunit-fixture" ),
allData = div.data();

equal( allData.nestedSingle, "single", "Key is correctly camelCased" );
equal( allData[ "nested-Double" ], "double", "Key with double hyphens is correctly camelCased" );
equal( allData[ "nested--Triple" ], "triple", "Key with triple hyphens is correctly camelCased" );
});

test(".data supports interoperable hyphenated/camelCase get/set of properties with arbitrary non-null|NaN|undefined values", function() {

var div = jQuery("<div/>", { id: "hyphened" }).appendTo("#qunit-fixture"),
Expand Down

0 comments on commit 172cad8

Please sign in to comment.