@@ -1055,6 +1055,105 @@ describe('jqLite', function() {
1055
1055
expect ( jqA . css ( 'z-index' ) ) . toBeOneOf ( '7' , 7 ) ;
1056
1056
expect ( jqA . css ( 'zIndex' ) ) . toBeOneOf ( '7' , 7 ) ;
1057
1057
} ) ;
1058
+
1059
+ it ( 'should leave non-dashed strings alone' , function ( ) {
1060
+ var jqA = jqLite ( a ) ;
1061
+
1062
+ jqA . css ( 'foo' , 'foo' ) ;
1063
+ jqA . css ( 'fooBar' , 'bar' ) ;
1064
+
1065
+ expect ( a . style . foo ) . toBe ( 'foo' ) ;
1066
+ expect ( a . style . fooBar ) . toBe ( 'bar' ) ;
1067
+ } ) ;
1068
+
1069
+ it ( 'should covert dash-separated strings to camelCase' , function ( ) {
1070
+ var jqA = jqLite ( a ) ;
1071
+
1072
+ jqA . css ( 'foo-bar' , 'foo' ) ;
1073
+ jqA . css ( 'foo-bar-baz' , 'bar' ) ;
1074
+ jqA . css ( 'foo:bar_baz' , 'baz' ) ;
1075
+
1076
+ expect ( a . style . fooBar ) . toBe ( 'foo' ) ;
1077
+ expect ( a . style . fooBarBaz ) . toBe ( 'bar' ) ;
1078
+ expect ( a . style [ 'foo:bar_baz' ] ) . toBe ( 'baz' ) ;
1079
+ } ) ;
1080
+
1081
+ it ( 'should covert leading dashes followed by a lowercase letter' , function ( ) {
1082
+ var jqA = jqLite ( a ) ;
1083
+
1084
+ jqA . css ( '-foo-bar' , 'foo' ) ;
1085
+
1086
+ expect ( a . style . FooBar ) . toBe ( 'foo' ) ;
1087
+ } ) ;
1088
+
1089
+ it ( 'should not convert slashes followed by a non-letter' , function ( ) {
1090
+ var jqA = jqLite ( a ) ;
1091
+
1092
+ jqA . css ( 'foo-42- -a-B' , 'foo' ) ;
1093
+
1094
+ expect ( a . style [ 'foo-42- A-B' ] ) . toBe ( 'foo' ) ;
1095
+ } ) ;
1096
+
1097
+ it ( 'should covert the -ms- prefix to ms instead of Ms' , function ( ) {
1098
+ var jqA = jqLite ( a ) ;
1099
+
1100
+ jqA . css ( '-ms-foo-bar' , 'foo' ) ;
1101
+ jqA . css ( '-moz-foo-bar' , 'bar' ) ;
1102
+ jqA . css ( '-webkit-foo-bar' , 'baz' ) ;
1103
+
1104
+ expect ( a . style . msFooBar ) . toBe ( 'foo' ) ;
1105
+ expect ( a . style . MozFooBar ) . toBe ( 'bar' ) ;
1106
+ expect ( a . style . WebkitFooBar ) . toBe ( 'baz' ) ;
1107
+ } ) ;
1108
+
1109
+ it ( 'should not collapse sequences of dashes' , function ( ) {
1110
+ var jqA = jqLite ( a ) ;
1111
+
1112
+ jqA . css ( 'foo---bar-baz--qaz' , 'foo' ) ;
1113
+
1114
+ expect ( a . style [ 'foo--BarBaz-Qaz' ] ) . toBe ( 'foo' ) ;
1115
+ } ) ;
1116
+
1117
+
1118
+ it ( 'should read vendor prefixes with the special -ms- exception' , function ( ) {
1119
+ // jQuery uses getComputedStyle() in a css getter so these tests would fail there.
1120
+ if ( ! _jqLiteMode ) return ;
1121
+
1122
+ var jqA = jqLite ( a ) ;
1123
+
1124
+ a . style . WebkitFooBar = 'webkit-uppercase' ;
1125
+ a . style . webkitFooBar = 'webkit-lowercase' ;
1126
+
1127
+ a . style . MozFooBaz = 'moz-uppercase' ;
1128
+ a . style . mozFooBaz = 'moz-lowercase' ;
1129
+
1130
+ a . style . MsFooQaz = 'ms-uppercase' ;
1131
+ a . style . msFooQaz = 'ms-lowercase' ;
1132
+
1133
+ expect ( jqA . css ( '-webkit-foo-bar' ) ) . toBe ( 'webkit-uppercase' ) ;
1134
+ expect ( jqA . css ( '-moz-foo-baz' ) ) . toBe ( 'moz-uppercase' ) ;
1135
+ expect ( jqA . css ( '-ms-foo-qaz' ) ) . toBe ( 'ms-lowercase' ) ;
1136
+ } ) ;
1137
+
1138
+ it ( 'should write vendor prefixes with the special -ms- exception' , function ( ) {
1139
+ // jQuery uses getComputedStyle() in a css getter so these tests would fail there.
1140
+ if ( ! _jqLiteMode ) return ;
1141
+
1142
+ var jqA = jqLite ( a ) ;
1143
+
1144
+ jqA . css ( '-webkit-foo-bar' , 'webkit' ) ;
1145
+ jqA . css ( '-moz-foo-baz' , 'moz' ) ;
1146
+ jqA . css ( '-ms-foo-qaz' , 'ms' ) ;
1147
+
1148
+ expect ( a . style . WebkitFooBar ) . toBe ( 'webkit' ) ;
1149
+ expect ( a . style . webkitFooBar ) . not . toBeDefined ( ) ;
1150
+
1151
+ expect ( a . style . MozFooBaz ) . toBe ( 'moz' ) ;
1152
+ expect ( a . style . mozFooBaz ) . not . toBeDefined ( ) ;
1153
+
1154
+ expect ( a . style . MsFooQaz ) . not . toBeDefined ( ) ;
1155
+ expect ( a . style . msFooQaz ) . toBe ( 'ms' ) ;
1156
+ } ) ;
1058
1157
} ) ;
1059
1158
1060
1159
@@ -2267,25 +2366,35 @@ describe('jqLite', function() {
2267
2366
} ) ;
2268
2367
2269
2368
2270
- describe ( 'camelCase ' , function ( ) {
2369
+ describe ( 'kebabToCamel ' , function ( ) {
2271
2370
it ( 'should leave non-dashed strings alone' , function ( ) {
2272
- expect ( camelCase ( 'foo' ) ) . toBe ( 'foo' ) ;
2273
- expect ( camelCase ( '' ) ) . toBe ( '' ) ;
2274
- expect ( camelCase ( 'fooBar' ) ) . toBe ( 'fooBar' ) ;
2371
+ expect ( kebabToCamel ( 'foo' ) ) . toBe ( 'foo' ) ;
2372
+ expect ( kebabToCamel ( '' ) ) . toBe ( '' ) ;
2373
+ expect ( kebabToCamel ( 'fooBar' ) ) . toBe ( 'fooBar' ) ;
2275
2374
} ) ;
2276
2375
2277
-
2278
2376
it ( 'should covert dash-separated strings to camelCase' , function ( ) {
2279
- expect ( camelCase ( 'foo-bar' ) ) . toBe ( 'fooBar' ) ;
2280
- expect ( camelCase ( 'foo-bar-baz' ) ) . toBe ( 'fooBarBaz' ) ;
2281
- expect ( camelCase ( 'foo:bar_baz' ) ) . toBe ( 'fooBarBaz' ) ;
2377
+ expect ( kebabToCamel ( 'foo-bar' ) ) . toBe ( 'fooBar' ) ;
2378
+ expect ( kebabToCamel ( 'foo-bar-baz' ) ) . toBe ( 'fooBarBaz' ) ;
2379
+ expect ( kebabToCamel ( 'foo:bar_baz' ) ) . toBe ( 'foo:bar_baz' ) ;
2380
+ } ) ;
2381
+
2382
+ it ( 'should covert leading dashes followed by a lowercase letter' , function ( ) {
2383
+ expect ( kebabToCamel ( '-foo-bar' ) ) . toBe ( 'FooBar' ) ;
2282
2384
} ) ;
2283
2385
2386
+ it ( 'should not convert slashes followed by a non-letter' , function ( ) {
2387
+ expect ( kebabToCamel ( 'foo-42- -a-B' ) ) . toBe ( 'foo-42- A-B' ) ;
2388
+ } ) ;
2389
+
2390
+ it ( 'should not covert browser specific css properties in a special way' , function ( ) {
2391
+ expect ( kebabToCamel ( '-ms-foo-bar' ) ) . toBe ( 'MsFooBar' ) ;
2392
+ expect ( kebabToCamel ( '-moz-foo-bar' ) ) . toBe ( 'MozFooBar' ) ;
2393
+ expect ( kebabToCamel ( '-webkit-foo-bar' ) ) . toBe ( 'WebkitFooBar' ) ;
2394
+ } ) ;
2284
2395
2285
- it ( 'should covert browser specific css properties' , function ( ) {
2286
- expect ( camelCase ( '-moz-foo-bar' ) ) . toBe ( 'MozFooBar' ) ;
2287
- expect ( camelCase ( '-webkit-foo-bar' ) ) . toBe ( 'webkitFooBar' ) ;
2288
- expect ( camelCase ( '-webkit-foo-bar' ) ) . toBe ( 'webkitFooBar' ) ;
2396
+ it ( 'should not collapse sequences of dashes' , function ( ) {
2397
+ expect ( kebabToCamel ( 'foo---bar-baz--qaz' ) ) . toBe ( 'foo--BarBaz-Qaz' ) ;
2289
2398
} ) ;
2290
2399
} ) ;
2291
2400
0 commit comments