From fc9f124c7cce810c2c6a108042c3fac9deab53a2 Mon Sep 17 00:00:00 2001 From: Kevin MacMartin Date: Thu, 2 Jul 2015 13:05:28 -0400 Subject: [PATCH] Fix parent position check before applying relative style if none of the valid positions are used --- contain-element.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/contain-element.js b/contain-element.js index 6f4d7ae..e84fd63 100644 --- a/contain-element.js +++ b/contain-element.js @@ -5,11 +5,9 @@ function ContainElement(options) { var elementHeight = options.height || element.offsetHeight; // Apply required attributes to the element and its parents if they aren't already set - if (element.style.position != 'absolute') - element.style.position = 'absolute'; - if (element.parentElement.style.overflow != 'hidden') - element.parentElement.style.overflow = 'hidden'; - if (['relative', 'absolute', 'fixed'].indexOf(element.parentElement.style.position) === -1) + element.style.position = 'absolute'; + element.parentElement.style.overflow = 'hidden'; + if (['relative', 'absolute', 'fixed'].indexOf(window.getComputedStyle(element.parentElement,null).getPropertyValue('position')) === -1) element.parentElement.style.position = 'relative'; function updateContain() {