From 7754829e1a4d3f50620fe5c9b9d3dbdaaf21fe45 Mon Sep 17 00:00:00 2001 From: Nathan Cahill Date: Thu, 22 Nov 2018 11:27:53 -0800 Subject: [PATCH] handle case in hidden iframes - fixes #171 --- packages/splitjs/src/split.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/splitjs/src/split.js b/packages/splitjs/src/split.js index a65774359..b6fd542cb 100644 --- a/packages/splitjs/src/split.js +++ b/packages/splitjs/src/split.js @@ -152,9 +152,8 @@ const Split = (idsOption, options = {}) => { // behavior will be whacky otherwise. const firstElement = elementOrSelector(ids[0]) const parent = firstElement.parentNode - const parentFlexDirection = getComputedStyle - ? getComputedStyle(parent).flexDirection - : null + const parentStyle = getComputedStyle ? getComputedStyle(parent) : null + const parentFlexDirection = parentStyle ? parentStyle.flexDirection : null // Set default options.sizes to equal percentages of the parent element. let sizes = getOption(options, 'sizes') || ids.map(() => 100 / ids.length) @@ -352,6 +351,9 @@ const Split = (idsOption, options = {}) => { if (!getComputedStyle) return null const computedStyle = getComputedStyle(element) + + if (!computedStyle) return null + let size = element[clientSize] if (size === 0) return null