Skip to content

Commit

Permalink
Remove IE8 property expansion workaround (#10803)
Browse files Browse the repository at this point in the history
* Remove IE8 property expansion workaround

* Edit from a plane ✈️
  • Loading branch information
gaearon committed Sep 27, 2017
1 parent ccb2f82 commit 2566b24
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 89 deletions.
63 changes: 0 additions & 63 deletions src/renderers/dom/shared/CSSProperty.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,71 +82,8 @@ Object.keys(isUnitlessNumber).forEach(function(prop) {
});
});

/**
* Most style properties can be unset by doing .style[prop] = '' but IE8
* doesn't like doing that with shorthand properties so for the properties that
* IE8 breaks on, which are listed here, we instead unset each of the
* individual properties. See http://bugs.jquery.com/ticket/12385.
* The 4-value 'clock' properties like margin, padding, border-width seem to
* behave without any problems. Curiously, list-style works too without any
* special prodding.
*/
var shorthandPropertyExpansions = {
background: {
backgroundAttachment: true,
backgroundColor: true,
backgroundImage: true,
backgroundPositionX: true,
backgroundPositionY: true,
backgroundRepeat: true,
},
backgroundPosition: {
backgroundPositionX: true,
backgroundPositionY: true,
},
border: {
borderWidth: true,
borderStyle: true,
borderColor: true,
},
borderBottom: {
borderBottomWidth: true,
borderBottomStyle: true,
borderBottomColor: true,
},
borderLeft: {
borderLeftWidth: true,
borderLeftStyle: true,
borderLeftColor: true,
},
borderRight: {
borderRightWidth: true,
borderRightStyle: true,
borderRightColor: true,
},
borderTop: {
borderTopWidth: true,
borderTopStyle: true,
borderTopColor: true,
},
font: {
fontStyle: true,
fontVariant: true,
fontWeight: true,
fontSize: true,
lineHeight: true,
fontFamily: true,
},
outline: {
outlineWidth: true,
outlineStyle: true,
outlineColor: true,
},
};

var CSSProperty = {
isUnitlessNumber: isUnitlessNumber,
shorthandPropertyExpansions: shorthandPropertyExpansions,
};

module.exports = CSSProperty;
27 changes: 1 addition & 26 deletions src/renderers/dom/shared/CSSPropertyOperations.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,13 @@

'use strict';

var CSSProperty = require('CSSProperty');
var ExecutionEnvironment = require('fbjs/lib/ExecutionEnvironment');

var dangerousStyleValue = require('dangerousStyleValue');

if (__DEV__) {
var hyphenateStyleName = require('fbjs/lib/hyphenateStyleName');
var warnValidStyle = require('warnValidStyle');
}

var hasShorthandPropertyBug = false;
if (ExecutionEnvironment.canUseDOM) {
var tempStyle = document.createElement('div').style;
try {
// IE8 throws "Invalid argument." if resetting shorthand style properties.
tempStyle.font = '';
} catch (e) {
hasShorthandPropertyBug = true;
}
}

/**
* Operations for dealing with CSS properties.
*/
Expand Down Expand Up @@ -98,18 +84,7 @@ var CSSPropertyOperations = {
} else if (styleValue) {
style[styleName] = styleValue;
} else {
var expansion =
hasShorthandPropertyBug &&
CSSProperty.shorthandPropertyExpansions[styleName];
if (expansion) {
// Shorthand property that IE8 won't like unsetting, so unset each
// component to placate it
for (var individualStyleName in expansion) {
style[individualStyleName] = '';
}
} else {
style[styleName] = '';
}
style[styleName] = '';
}
}
},
Expand Down

0 comments on commit 2566b24

Please sign in to comment.