Skip to content

Commit

Permalink
fix with cleaner code
Browse files Browse the repository at this point in the history
  • Loading branch information
senpl committed Jul 1, 2024
1 parent 0759e35 commit 35dd425
Showing 1 changed file with 2 additions and 27 deletions.
29 changes: 2 additions & 27 deletions packages/driver/src/dom/visibility.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,31 +178,6 @@ const elHasNoEffectiveWidthOrHeight = ($el, parent = false) => {
const height = elOffsetHeight($el)
const overflowHidden = elHasOverflowHidden($el)

return isZeroLengthAndTransformNone(width, height, transform) ||
isZeroLengthAndOverflowHidden(width, height, overflowHidden) ||
(el.getClientRects().length <= 0)
}

const elHasNoEffectiveWidthOrHeight2 = ($el, parent = true) => {
// Is the element's CSS width OR height, including any borders,
// padding, and vertical scrollbars (if rendered) less than 0?
//
// elOffsetWidth:
// If the element is hidden (for example, by setting style.display
// on the element or one of its ancestors to "none"), then 0 is returned.

// $el[0].getClientRects().length:
// For HTML <area> elements, SVG elements that do not render anything themselves,
// display:none elements, and generally any elements that are not directly rendered,
// an empty list is returned.

const el = $el[0]
const style = getComputedStyle(el)
const transform = style.getPropertyValue('transform')
const width = elOffsetWidth($el)
const height = elOffsetHeight($el)
const overflowHidden = elHasOverflowHidden($el)

return ((parent ? elOffsetWidth($el) <= 0 : false)
&& isZeroLengthAndTransformNone(width, height, transform)) ||
isZeroLengthAndOverflowHidden(width, height, overflowHidden) ||
Expand Down Expand Up @@ -437,7 +412,7 @@ const elIsHiddenByAncestors = function ($el, checkOpacity, $origEl = $el) {
return true
}

if (elHasOverflowHidden($parent) && elHasNoEffectiveWidthOrHeight2($parent)) {
if (elHasOverflowHidden($parent) && elHasNoEffectiveWidthOrHeight($parent, true)) {
// if any of the elements between the parent and origEl
// have fixed or position absolute
return !elDescendentsHavePositionFixedOrAbsolute($parent, $origEl)
Expand All @@ -454,7 +429,7 @@ const parentHasNoOffsetWidthOrHeightAndOverflowHidden = function ($el) {
}

// if we have overflow hidden and no effective width or height
if (elHasOverflowHidden($el) && elHasNoEffectiveWidthOrHeight2($el)) {
if (elHasOverflowHidden($el) && elHasNoEffectiveWidthOrHeight($el)) {
return $el
}

Expand Down

0 comments on commit 35dd425

Please sign in to comment.