diff --git a/src/iframeResizer.contentWindow.js b/src/iframeResizer.contentWindow.js index c77643f07..f0c7c6ad0 100644 --- a/src/iframeResizer.contentWindow.js +++ b/src/iframeResizer.contentWindow.js @@ -645,7 +645,7 @@ // document.documentElement.offsetHeight is not reliable, so // we have to jump through hoops to get a better value. - function getComputedBodyStyle(prop) { + function getComputedStyle(prop,el) { /* istanbul ignore next */ //Not testable in PhantomJS function convertUnitsToPxForIE8(value) { var PIXEL = /^\d+(px)?$/i; @@ -667,9 +667,8 @@ return value; } - var - el = document.body, - retVal = 0; + var retVal = 0; + el = el || document.body; /* istanbul ignore else */ // Not testable in phantonJS if (('defaultView' in document) && ('getComputedStyle' in document.defaultView)) { @@ -699,7 +698,7 @@ timer = getNow(); for (var i = 0; i < elementsLength; i++) { - elVal = elements[i].getBoundingClientRect()[side] + getComputedBodyStyle('margin'+Side); + elVal = elements[i].getBoundingClientRect()[side] + getComputedStyle('margin'+Side,elements[i]); if (elVal > maxVal) { maxVal = elVal; } @@ -742,7 +741,7 @@ var getHeight = { bodyOffset: function getBodyOffsetHeight(){ - return document.body.offsetHeight + getComputedBodyStyle('marginTop') + getComputedBodyStyle('marginBottom'); + return document.body.offsetHeight + getComputedStyle('marginTop') + getComputedStyle('marginBottom'); }, offset: function(){