1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-08-07 22:26:57 +02:00

Refactor isVisible helper, fixing false positives from deep nesting or alternate means (#33960)

This commit is contained in:
Ryan Berliner
2021-05-20 09:50:53 -04:00
committed by GitHub
parent 79c3bf47bc
commit 4ac711b5b4
2 changed files with 52 additions and 13 deletions

View File

@@ -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 => {