Skip to content

Commit 8753619

Browse files
Merge pull request #2686 from timwienk/master
Element/Element.Style.js: Fix camelCasing of -ms- prefixed properties.
2 parents 652ee5f + 8625fbd commit 8753619

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

Source/Element/Element.Style.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,12 @@ var getOpacity = (hasOpacity ? function(element){
8585

8686
var floatName = (html.style.cssFloat == null) ? 'styleFloat' : 'cssFloat',
8787
namedPositions = {left: '0%', top: '0%', center: '50%', right: '100%', bottom: '100%'},
88-
hasBackgroundPositionXY = (html.style.backgroundPositionX != null);
88+
hasBackgroundPositionXY = (html.style.backgroundPositionX != null),
89+
prefixPattern = /^-(ms)-/;
90+
91+
var camelCase = function(property){
92+
return property.replace(prefixPattern, '$1-').camelCase();
93+
}
8994

9095
//<ltIE9>
9196
var removeStyle = function(style, property){
@@ -100,7 +105,7 @@ var removeStyle = function(style, property){
100105
Element.implement({
101106

102107
getComputedStyle: function(property){
103-
if (!hasGetComputedStyle && this.currentStyle) return this.currentStyle[property.camelCase()];
108+
if (!hasGetComputedStyle && this.currentStyle) return this.currentStyle[camelCase(property)];
104109
var defaultView = Element.getDocument(this).defaultView,
105110
computed = defaultView ? defaultView.getComputedStyle(this, null) : null;
106111
return (computed) ? computed.getPropertyValue((property == floatName) ? 'float' : property.hyphenate()) : '';
@@ -112,7 +117,7 @@ Element.implement({
112117
setOpacity(this, value);
113118
return this;
114119
}
115-
property = (property == 'float' ? floatName : property).camelCase();
120+
property = camelCase(property == 'float' ? floatName : property);
116121
if (typeOf(value) != 'string'){
117122
var map = (Element.Styles[property] || '@').split(' ');
118123
value = Array.from(value).map(function(val, i){
@@ -133,7 +138,7 @@ Element.implement({
133138

134139
getStyle: function(property){
135140
if (property == 'opacity') return getOpacity(this);
136-
property = (property == 'float' ? floatName : property).camelCase();
141+
property = camelCase(property == 'float' ? floatName : property);
137142
if (supportBorderRadius && property.indexOf('borderRadius') != -1){
138143
return ['borderTopLeftRadius', 'borderTopRightRadius', 'borderBottomRightRadius', 'borderBottomLeftRadius'].map(function(corner){
139144
return this.style[corner] || '0px';

0 commit comments

Comments
 (0)