Skip to content

Commit b22c904

Browse files
committed
Merge pull request jquery#456 from rwldrn/9318
Improves support for arbitrary numbers in data keys. Fixes #9318
2 parents 37254ba + e7af6a2 commit b22c904

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/core.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@ var jQuery = function( selector, context ) {
4646
rmozilla = /(mozilla)(?:.*? rv:([\w.]+))?/,
4747

4848
// Matches dashed string for camelizing
49-
rdashAlpha = /-([a-z])/ig,
49+
rdashAlpha = /-([a-z]|[0-9])/ig,
5050

5151
// Used by jQuery.camelCase as callback to replace()
5252
fcamelCase = function( all, letter ) {
53-
return letter.toUpperCase();
53+
return ( letter + "" ).toUpperCase();
5454
},
5555

5656
// Keep a UserAgent string for use with jQuery.browser

test/unit/data.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -538,10 +538,13 @@ test("jQuery.data supports interoperable hyphenated/camelCase get/set of propert
538538
"an-object": {},
539539
"bool-true": true,
540540
"bool-false": false,
541-
"some-json": '{ "foo": "bar" }'
541+
"some-json": '{ "foo": "bar" }',
542+
"num-1-middle": true,
543+
"num-end-2": true,
544+
"2-num-start": true
542545
};
543546

544-
expect( 18 );
547+
expect( 24 );
545548

546549
jQuery.each( datas, function( key, val ) {
547550
div.data( key, val );
@@ -578,4 +581,4 @@ test("jQuery.data supports interoperable removal of hyphenated/camelCase propert
578581
equal( div.data( key ), undefined, "get: " + key );
579582

580583
});
581-
});
584+
});

0 commit comments

Comments
 (0)