diff --git a/src/js/component.js b/src/js/component.js index d9367fb486..db9b295c0c 100644 --- a/src/js/component.js +++ b/src/js/component.js @@ -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; }