Skip to content

Commit

Permalink
fix: currentDimension can return 0 for fluid player on IE (#3738)
Browse files Browse the repository at this point in the history
This is because IE returns 0 for both getComputedStyle and currentStyle.
However, offsetHeight and offsetWidth do contain the correct values we
want. So, if before returning in currentDimension the return value is
still zero, check the offset values.
  • Loading branch information
gkatsev authored Nov 3, 2016
1 parent 2e720af commit 74cddca
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/js/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -1148,16 +1148,20 @@ class Component {
const computedStyle = window.getComputedStyle(this.el_);

computedWidthOrHeight = computedStyle.getPropertyValue(widthOrHeight) || computedStyle[widthOrHeight];
} else if (this.el_.currentStyle) {
// ie 8 doesn't support computed style, shim it
// return clientWidth or clientHeight instead for better accuracy
}

// remove 'px' from variable and parse as integer
computedWidthOrHeight = parseFloat(computedWidthOrHeight);

// if the computed value is still 0, it's possible that the browser is lying
// and we want to check the offset values.
// This code also runs on IE8 and wherever getComputedStyle doesn't exist.
if (computedWidthOrHeight === 0) {
const rule = `offset${toTitleCase(widthOrHeight)}`;

computedWidthOrHeight = this.el_[rule];
}

// remove 'px' from variable and parse as integer
computedWidthOrHeight = parseFloat(computedWidthOrHeight);
return computedWidthOrHeight;
}

Expand Down

0 comments on commit 74cddca

Please sign in to comment.