Skip to content

Commit f4f22a0

Browse files
syranidesophiebits
authored andcommitted
Apply CSS shorthand expansion to IE8 only
Closes facebook#1953.
1 parent 3de7a28 commit f4f22a0

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/renderers/dom/shared/CSSPropertyOperations.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,16 @@ var processStyleName = memoizeStringOnly(function(styleName) {
2525
return hyphenateStyleName(styleName);
2626
});
2727

28+
var hasShorthandPropertyBug = false;
2829
var styleFloatAccessor = 'cssFloat';
2930
if (ExecutionEnvironment.canUseDOM) {
31+
var tempStyle = document.createElement('div').style;
32+
try {
33+
// IE8 throws "Invalid argument." if resetting shorthand style properties.
34+
tempStyle.font = '';
35+
} catch (e) {
36+
hasShorthandPropertyBug = true;
37+
}
3038
// IE8 only supports accessing cssFloat (standard) as styleFloat
3139
if (document.documentElement.style.cssFloat === undefined) {
3240
styleFloatAccessor = 'styleFloat';
@@ -159,7 +167,9 @@ var CSSPropertyOperations = {
159167
if (styleValue) {
160168
style[styleName] = styleValue;
161169
} else {
162-
var expansion = CSSProperty.shorthandPropertyExpansions[styleName];
170+
var expansion =
171+
hasShorthandPropertyBug &&
172+
CSSProperty.shorthandPropertyExpansions[styleName];
163173
if (expansion) {
164174
// Shorthand property that IE8 won't like unsetting, so unset each
165175
// component to placate it

0 commit comments

Comments
 (0)