Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/twbs/bootstrap.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohann-S <johann.servoire@gmail.com>2017-11-30 12:54:27 +0300
committerJohann-S <johann.servoire@gmail.com>2018-12-05 18:02:59 +0300
commitb16127fc105f159ebd06b02df2853941b2aba67c (patch)
tree45f5a0138c633e0e3aa6bd5357ffef4d14c8bc6f /js/src/util.js
parent850d99bb13b895b83a860c38092755253ceb5b4a (diff)
Allow Tooltips/Popovers to work in shadow DOM
Diffstat (limited to 'js/src/util.js')
-rw-r--r--js/src/util.js23
1 files changed, 23 insertions, 0 deletions
diff --git a/js/src/util.js b/js/src/util.js
index e9665d24fd..1d804cf9da 100644
--- a/js/src/util.js
+++ b/js/src/util.js
@@ -142,6 +142,29 @@ const Util = {
}
}
}
+ },
+
+ findShadowRoot(element) {
+ if (!document.documentElement.attachShadow) {
+ return null
+ }
+
+ // Can find the shadow root otherwise it'll return the document
+ if (typeof element.getRootNode === 'function') {
+ const 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)
}
}