Skip to content

Commit 1a738cb

Browse files
dmethvintimmywil
authored andcommitted
Landing pull request 463. Fixes #9572. Don't camelize the -ms- prefix because Microsoft didn't. A Fixes #9572.
More Details: - jquery#463 - http://bugs.jquery.com/ticket/9572
1 parent 130a29e commit 1a738cb

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

src/core.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ var jQuery = function( selector, context ) {
4747

4848
// Matches dashed string for camelizing
4949
rdashAlpha = /-([a-z]|[0-9])/ig,
50+
rmsPrefix = /^-ms-/,
5051

5152
// Used by jQuery.camelCase as callback to replace()
5253
fcamelCase = function( all, letter ) {
@@ -590,10 +591,10 @@ jQuery.extend({
590591
}
591592
},
592593

593-
// Converts a dashed string to camelCased string;
594-
// Used by both the css and data modules
594+
// Convert dashed to camelCase; used by the css and data modules
595+
// Microsoft forgot to hump their vendor prefix (#9572)
595596
camelCase: function( string ) {
596-
return string.replace( rdashAlpha, fcamelCase );
597+
return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
597598
},
598599

599600
nodeName: function( elem, name ) {

test/unit/core.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1129,10 +1129,15 @@ test("jQuery.camelCase()", function() {
11291129

11301130
var tests = {
11311131
"foo-bar": "fooBar",
1132-
"foo-bar-baz": "fooBarBaz"
1132+
"foo-bar-baz": "fooBarBaz",
1133+
"girl-u-want": "girlUWant",
1134+
"the-4th-dimension": "the4thDimension",
1135+
"-o-tannenbaum": "OTannenbaum",
1136+
"-moz-illa": "MozIlla",
1137+
"-ms-take": "msTake"
11331138
};
11341139

1135-
expect(2);
1140+
expect(7);
11361141

11371142
jQuery.each( tests, function( key, val ) {
11381143
equal( jQuery.camelCase( key ), val, "Converts: " + key + " => " + val );

0 commit comments

Comments
 (0)