Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for margin issue #286

Merged
merged 4 commits into from
Nov 4, 2015
Merged
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: 5 additions & 6 deletions src/iframeResizer.contentWindow.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)) {
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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(){
Expand Down