Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/browser/ui/dom/CSSPropertyOperations.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,15 @@ var processStyleName = memoizeStringOnly(function(styleName) {
return hyphenateStyleName(styleName);
});

var hasShorthandPropertyBug = false;
var styleFloatAccessor = 'cssFloat';
if (ExecutionEnvironment.canUseDOM) {
try {
// IE8 throws "Invalid argument." if resetting shorthand style properties.
document.createElement('div').style.font = '';
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does this throw? All the info online I can find indicate that it silently does the wrong thing.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

>>document.createElement('div').style.font = '';
  "Invalid argument." (error)
>>document.createElement('div').style.fontSize = '';
  ""

} catch (e) {
hasShorthandPropertyBug = true;
}
// IE8 only supports accessing cssFloat (standard) as styleFloat
if (document.documentElement.style.cssFloat === undefined) {
styleFloatAccessor = 'styleFloat';
Expand Down Expand Up @@ -118,7 +125,7 @@ var CSSPropertyOperations = {
}
if (styleValue) {
style[styleName] = styleValue;
} else {
} else if (hasShorthandPropertyBug) {
var expansion = CSSProperty.shorthandPropertyExpansions[styleName];
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe just do expansion = hasShorthandPropertyBug && ...; to avoid the duplication in style[styleName] = '';? Otherwise looks good to me.

if (expansion) {
// Shorthand property that IE8 won't like unsetting, so unset each
Expand All @@ -129,6 +136,8 @@ var CSSPropertyOperations = {
} else {
style[styleName] = '';
}
} else {
style[styleName] = '';
}
}
}
Expand Down