Skip to content

Commit

Permalink
remove whitespace from textContent since that cannot be seen.
Browse files Browse the repository at this point in the history
  • Loading branch information
jennifer-shehane committed Nov 7, 2024
1 parent 9847e19 commit 1b6d74b
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions packages/driver/src/dom/visibility.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import * as $transform from './transform'
const { isElement, isBody, isHTML, isOption, isOptgroup, getParent, getFirstParentWithTagName, isAncestor, isChild, getAllParents, isDescendent, isUndefinedOrHTMLBodyDoc, elOrAncestorIsFixedOrSticky, isDetached, isFocusable, stringify: stringifyElement } = $elements

const fixedOrAbsoluteRe = /(fixed|absolute)/
const whitespaceRegex = /\s/g

const OVERFLOW_PROPS = ['hidden', 'scroll', 'auto']

Expand Down Expand Up @@ -106,11 +107,11 @@ const isStrictlyHidden = (el, methodName = 'isStrictlyHidden()', options = { che
return !elHasVisibleChild($el)
}

// the presence of text content should make the element visible
// the presence of text content that is not just
// spaces or newlines should make the element visible
// since you can see the text with your eyes
// unless it is explicitly hidden in some way
if (el.textContent) {
// this below should be in function
if (el.textContent.replace(whitespaceRegex, '')) {
// unless it is explicitly hidden in some way
return hasExplicitNonVisibleProps($el, options)
}

Expand Down

0 comments on commit 1b6d74b

Please sign in to comment.