From 31d59b26bf2fc9c2bcfcddad67c4abd29ae4e837 Mon Sep 17 00:00:00 2001 From: Brendan Keogh Date: Mon, 19 Apr 2021 20:16:06 -0600 Subject: [PATCH] Adding a check to see if the element is a prototype of Element before getting the computed style --- src/helpers/tabbable.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/helpers/tabbable.js b/src/helpers/tabbable.js index f83f1480..8a64bd9a 100644 --- a/src/helpers/tabbable.js +++ b/src/helpers/tabbable.js @@ -18,6 +18,12 @@ function hidesContents(element) { // If the node is empty, this is good enough if (zeroSize && !element.innerHTML) return true; + // if the element is not of type Element e.g. shadowRoot + // we cannot go any further + if (!element.isPrototypeOf(Element)) { + return false; + } + // Otherwise we need to check some styles const style = window.getComputedStyle(element); return zeroSize