From 6347d778352caecb7921c475dcce8e7705940106 Mon Sep 17 00:00:00 2001 From: Dan Ballance Date: Mon, 2 Nov 2015 12:28:59 +0000 Subject: [PATCH 1/4] Fixes davidjbradshaw/iframe-resizer#281 --- src/iframeResizer.contentWindow.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/iframeResizer.contentWindow.js b/src/iframeResizer.contentWindow.js index c77643f07..911f3947a 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 getComputedBodyStyle(prop,el) { /* istanbul ignore next */ //Not testable in PhantomJS function convertUnitsToPxForIE8(value) { var PIXEL = /^\d+(px)?$/i; @@ -668,7 +668,7 @@ } var - el = document.body, + el = typeof el !== 'undefined' ? el : document.body, retVal = 0; /* istanbul ignore else */ // Not testable in phantonJS @@ -699,7 +699,7 @@ timer = getNow(); for (var i = 0; i < elementsLength; i++) { - elVal = elements[i].getBoundingClientRect()[side] + getComputedBodyStyle('margin'+Side); + elVal = elements[i].getBoundingClientRect()[side] + getComputedBodyStyle('margin'+Side,elements[i]); if (elVal > maxVal) { maxVal = elVal; } From e15e47bd588f9cca6219e0fb956f7c0b3224b92f Mon Sep 17 00:00:00 2001 From: Dan Ballance Date: Mon, 2 Nov 2015 12:33:21 +0000 Subject: [PATCH 2/4] Fixed an issue detected by jshint --- src/iframeResizer.contentWindow.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/iframeResizer.contentWindow.js b/src/iframeResizer.contentWindow.js index 911f3947a..4100eea06 100644 --- a/src/iframeResizer.contentWindow.js +++ b/src/iframeResizer.contentWindow.js @@ -667,9 +667,8 @@ return value; } - var - el = typeof el !== 'undefined' ? el : document.body, - retVal = 0; + var retVal = 0; + el = typeof el !== 'undefined' ? el : document.body; /* istanbul ignore else */ // Not testable in phantonJS if (('defaultView' in document) && ('getComputedStyle' in document.defaultView)) { From e6a231460239a5fda9c7f4990be8fd8e8ce5c985 Mon Sep 17 00:00:00 2001 From: Dan Ballance Date: Tue, 3 Nov 2015 08:41:30 +0000 Subject: [PATCH 3/4] Renamed function getComputedBodyStyle to getComputedBody --- src/iframeResizer.contentWindow.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/iframeResizer.contentWindow.js b/src/iframeResizer.contentWindow.js index 4100eea06..319f3c102 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,el) { + function getComputedStyle(prop,el) { /* istanbul ignore next */ //Not testable in PhantomJS function convertUnitsToPxForIE8(value) { var PIXEL = /^\d+(px)?$/i; @@ -698,7 +698,7 @@ timer = getNow(); for (var i = 0; i < elementsLength; i++) { - elVal = elements[i].getBoundingClientRect()[side] + getComputedBodyStyle('margin'+Side,elements[i]); + elVal = elements[i].getBoundingClientRect()[side] + getComputedStyle('margin'+Side,elements[i]); if (elVal > maxVal) { maxVal = elVal; } @@ -741,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(){ From 60ec25bbd15a34e1590801e6c6049cbc88b6ff71 Mon Sep 17 00:00:00 2001 From: Dan Ballance Date: Tue, 3 Nov 2015 08:43:23 +0000 Subject: [PATCH 4/4] Improved syntax for handling default value of el parameter in getComputedStyle() --- src/iframeResizer.contentWindow.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/iframeResizer.contentWindow.js b/src/iframeResizer.contentWindow.js index 319f3c102..f0c7c6ad0 100644 --- a/src/iframeResizer.contentWindow.js +++ b/src/iframeResizer.contentWindow.js @@ -668,7 +668,7 @@ } var retVal = 0; - el = typeof el !== 'undefined' ? el : document.body; + el = el || document.body; /* istanbul ignore else */ // Not testable in phantonJS if (('defaultView' in document) && ('getComputedStyle' in document.defaultView)) {