diff options
Diffstat (limited to 'js/dist/util.js')
-rw-r--r-- | js/dist/util.js | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/js/dist/util.js b/js/dist/util.js index d7c717ee51..baac0ff817 100644 --- a/js/dist/util.js +++ b/js/dist/util.js @@ -136,6 +136,28 @@ } } } + }, + findShadowRoot: function findShadowRoot(element) { + if (!document.documentElement.attachShadow) { + return null; + } // Can find the shadow root otherwise it'll return the document + + + if (typeof element.getRootNode === 'function') { + var root = element.getRootNode(); + return root instanceof ShadowRoot ? root : null; + } + + if (element instanceof ShadowRoot) { + return element; + } // when we don't find a shadow root + + + if (!element.parentNode) { + return null; + } + + return Util.findShadowRoot(element.parentNode); } }; setTransitionEndSupport(); |