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
path: root/js/src/util
diff options
context:
space:
mode:
authorRyan Berliner <22206986+RyanBerliner@users.noreply.github.com>2021-05-20 16:50:53 +0300
committerGitHub <noreply@github.com>2021-05-20 16:50:53 +0300
commit4ac711b5b4c0f733870cd8dd1f18b73f964275fc (patch)
treec91ecac7b95b6e8fd8f82ca58d66ada9dd3be809 /js/src/util
parent79c3bf47bc125fd64cf8cac6cd34b03270d34e2d (diff)
Refactor `isVisible` helper, fixing false positives from deep nesting or alternate means (#33960)
Diffstat (limited to 'js/src/util')
-rw-r--r--js/src/util/index.js13
1 files changed, 2 insertions, 11 deletions
diff --git a/js/src/util/index.js b/js/src/util/index.js
index 6b38a05e94..77bdc072fc 100644
--- a/js/src/util/index.js
+++ b/js/src/util/index.js
@@ -159,20 +159,11 @@ const typeCheckConfig = (componentName, config, configTypes) => {
}
const isVisible = element => {
- if (!element) {
+ if (!isElement(element) || element.getClientRects().length === 0) {
return false
}
- if (element.style && element.parentNode && element.parentNode.style) {
- const elementStyle = getComputedStyle(element)
- const parentNodeStyle = getComputedStyle(element.parentNode)
-
- return elementStyle.display !== 'none' &&
- parentNodeStyle.display !== 'none' &&
- elementStyle.visibility !== 'hidden'
- }
-
- return false
+ return getComputedStyle(element).getPropertyValue('visibility') === 'visible'
}
const isDisabled = element => {