Skip to content

Commit f67d18c

Browse files
authored
refactor: use checkVisibility when supported by browser (#8708)
1 parent 1b0331b commit f67d18c

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

‎packages/a11y-base/src/focus-utils.js‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,13 @@ function sortElementsByTabIndex(elements) {
145145
* @return {boolean}
146146
*/
147147
export function isElementHidden(element) {
148+
if (element.checkVisibility) {
149+
return !element.checkVisibility({ visibilityProperty: true });
150+
}
151+
152+
// TODO: checkVisibility is supported only from Safari 17.4, so we still need to
153+
// keep the custom implementation as a fallback for older versions until Vaadin 25:
154+
148155
// `offsetParent` is `null` when the element itself
149156
// or one of its ancestors is hidden with `display: none`.
150157
// https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetParent

0 commit comments

Comments
 (0)