From 1b6d74bc4f293c5a5c3e6fc4e5f6b276ac59d3e5 Mon Sep 17 00:00:00 2001 From: Jennifer Shehane Date: Thu, 7 Nov 2024 13:33:57 -0500 Subject: [PATCH] remove whitespace from textContent since that cannot be seen. --- packages/driver/src/dom/visibility.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/driver/src/dom/visibility.ts b/packages/driver/src/dom/visibility.ts index 34bc3fd08ca3..e2980ff337d1 100644 --- a/packages/driver/src/dom/visibility.ts +++ b/packages/driver/src/dom/visibility.ts @@ -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'] @@ -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) }