Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8fae212

Browse files
authored
Data: Separate data & css/effects camelCase implementations
The camelCase implementation used by the data module no longer turns `-ms-foo`into `msFoo` but to `MsFoo` now. This is because `data` is supposed to bea generic utility not specifically bound to CSS use cases.Fixesgh-3355Closesgh-4365
1 parenteb6c0a7 commit8fae212

File tree

7 files changed

+68
-18
lines changed

7 files changed

+68
-18
lines changed

‎src/core/camelCase.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,16 @@ define( [], function() {
33
"use strict";
44

55
// Matches dashed string for camelizing
6-
varrmsPrefix=/^-ms-/,
7-
rdashAlpha=/-([a-z])/g;
6+
varrdashAlpha=/-([a-z])/g;
87

98
// Used by camelCase as callback to replace()
109
functionfcamelCase(all,letter){
1110
returnletter.toUpperCase();
1211
}
1312

14-
// Convert dashed to camelCase; used by the css and data modules
15-
// Support: IE <=9 - 11, Edge 12 - 15
16-
// Microsoft forgot to hump their vendor prefix (#9572)
13+
// Convert dashed to camelCase
1714
functioncamelCase(string){
18-
returnstring.replace(rmsPrefix,"ms-").replace(rdashAlpha,fcamelCase);
15+
returnstring.replace(rdashAlpha,fcamelCase);
1916
}
2017

2118
returncamelCase;

‎src/css.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
define([
22
"./core",
33
"./core/access",
4-
"./core/camelCase",
54
"./var/rcssNum",
65
"./css/var/rnumnonpx",
76
"./css/var/cssExpand",
87
"./css/isAutoPx",
8+
"./css/cssCamelCase",
99
"./css/var/getStyles",
1010
"./css/var/swap",
1111
"./css/curCSS",
@@ -17,7 +17,7 @@ define( [
1717
"./core/init",
1818
"./core/ready",
1919
"./selector"// contains
20-
],function(jQuery,access,camelCase,rcssNum,rnumnonpx,cssExpand,isAutoPx,
20+
],function(jQuery,access,rcssNum,rnumnonpx,cssExpand,isAutoPx,cssCamelCase,
2121
getStyles,swap,curCSS,adjustCSS,addGetHookIf,support,finalPropName){
2222

2323
"use strict";
@@ -213,7 +213,7 @@ jQuery.extend( {
213213

214214
// Make sure that we're working with the right name
215215
varret,type,hooks,
216-
origName=camelCase(name),
216+
origName=cssCamelCase(name),
217217
isCustomProp=rcustomProp.test(name),
218218
style=elem.style;
219219

@@ -281,7 +281,7 @@ jQuery.extend( {
281281

282282
css:function(elem,name,extra,styles){
283283
varval,num,hooks,
284-
origName=camelCase(name),
284+
origName=cssCamelCase(name),
285285
isCustomProp=rcustomProp.test(name);
286286

287287
// Make sure that we're working with the right name. We don't

‎src/css/cssCamelCase.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
define([
2+
"../core/camelCase"
3+
],function(camelCase){
4+
5+
"use strict";
6+
7+
// Matches dashed string for camelizing
8+
varrmsPrefix=/^-ms-/;
9+
10+
// Convert dashed to camelCase, handle vendor prefixes.
11+
// Used by the css & effects modules.
12+
// Support: IE <=9 - 11+, Edge 12 - 18+
13+
// Microsoft forgot to hump their vendor prefix (#9572)
14+
functioncssCamelCase(string){
15+
returncamelCase(string.replace(rmsPrefix,"ms-"));
16+
}
17+
18+
returncssCamelCase;
19+
20+
});

‎src/deprecated.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
define([
22
"./core",
33
"./core/nodeName",
4-
"./core/camelCase",
54
"./core/toType",
5+
"./css/cssCamelCase",
66
"./var/isFunction",
77
"./var/isWindow",
88
"./var/slice",
99

1010
"./event/alias"
11-
],function(jQuery,nodeName,camelCase,toType,isFunction,isWindow,slice){
11+
],function(jQuery,nodeName,toType,cssCamelCase,isFunction,isWindow,slice){
1212

1313
"use strict";
1414

@@ -76,7 +76,7 @@ jQuery.parseJSON = JSON.parse;
7676
jQuery.nodeName=nodeName;
7777
jQuery.isFunction=isFunction;
7878
jQuery.isWindow=isWindow;
79-
jQuery.camelCase=camelCase;
79+
jQuery.camelCase=cssCamelCase;
8080
jQuery.type=toType;
8181

8282
jQuery.now=Date.now;

‎src/effects.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
define([
22
"./core",
3-
"./core/camelCase",
43
"./var/document",
54
"./var/isFunction",
65
"./var/rcssNum",
@@ -9,6 +8,7 @@ define( [
98
"./css/var/isHiddenWithinTree",
109
"./css/var/swap",
1110
"./css/adjustCSS",
11+
"./css/cssCamelCase",
1212
"./data/var/dataPriv",
1313
"./css/showHide",
1414

@@ -19,8 +19,8 @@ define( [
1919
"./manipulation",
2020
"./css",
2121
"./effects/Tween"
22-
],function(jQuery,camelCase,document,isFunction,rcssNum,rnothtmlwhite,cssExpand,
23-
isHiddenWithinTree,swap,adjustCSS,dataPriv,showHide){
22+
],function(jQuery,document,isFunction,rcssNum,rnothtmlwhite,cssExpand,
23+
isHiddenWithinTree,swap,adjustCSS,cssCamelCase,dataPriv,showHide){
2424

2525
"use strict";
2626

@@ -261,7 +261,7 @@ function propFilter( props, specialEasing ) {
261261

262262
// camelCase, specialEasing and expand cssHook pass
263263
for(indexinprops){
264-
name=camelCase(index);
264+
name=cssCamelCase(index);
265265
easing=specialEasing[name];
266266
value=props[index];
267267
if(Array.isArray(value)){

‎test/unit/css.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1885,3 +1885,18 @@ QUnit.test( "Do not throw on frame elements from css method (#15098)", function(
18851885
})();
18861886

18871887
}
1888+
1889+
// Support: IE 11+
1890+
if(document.documentMode){
1891+
// Make sure explicitly provided IE vendor prefix (`-ms-`) is not converted
1892+
// to a non-working `Ms` prefix in JavaScript.
1893+
QUnit.test("IE vendor prefixes are not mangled",function(assert){
1894+
assert.expect(1);
1895+
1896+
vardiv=jQuery("<div>").appendTo("#qunit-fixture");
1897+
1898+
div.css("-ms-grid-row","1");
1899+
1900+
assert.strictEqual(div.css("-ms-grid-row"),"1","IE vendor prefixing");
1901+
});
1902+
}

‎test/unit/data.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -722,10 +722,28 @@ QUnit.test( ".data supports interoperable hyphenated/camelCase get/set of proper
722722
"2-num-start":{
723723
key:"2NumStart",
724724
value:true
725+
},
726+
727+
// Vendor prefixes are not treated in a special way.
728+
"-ms-foo":{
729+
key:"MsFoo",
730+
value:true
731+
},
732+
"-moz-foo":{
733+
key:"MozFoo",
734+
value:true
735+
},
736+
"-webkit-foo":{
737+
key:"WebkitFoo",
738+
value:true
739+
},
740+
"-fake-foo":{
741+
key:"FakeFoo",
742+
value:true
725743
}
726744
};
727745

728-
assert.expect(24);
746+
assert.expect(32);
729747

730748
jQuery.each(datas,function(key,val){
731749
div.data(key,val.value);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp