diff --git a/src/helpers/tabbable.js b/src/helpers/tabbable.js index f83f1480..f2ebbc9c 100644 --- a/src/helpers/tabbable.js +++ b/src/helpers/tabbable.js @@ -18,13 +18,19 @@ function hidesContents(element) { // If the node is empty, this is good enough if (zeroSize && !element.innerHTML) return true; - // Otherwise we need to check some styles - const style = window.getComputedStyle(element); - return zeroSize - ? style.getPropertyValue("overflow") !== "visible" || - // if 'overflow: visible' set, check if there is actually any overflow - (element.scrollWidth <= 0 && element.scrollHeight <= 0) - : style.getPropertyValue("display") == "none"; + try { + // Otherwise we need to check some styles + const style = window.getComputedStyle(element); + return zeroSize + ? style.getPropertyValue("overflow") !== "visible" || + // if 'overflow: visible' set, check if there is actually any overflow + (element.scrollWidth <= 0 && element.scrollHeight <= 0) + : style.getPropertyValue("display") == "none"; + } catch (exception) { + // eslint-disable-next-line no-console + console.warn("Failed to inspect element style"); + return false; + } } function visible(element) {