Skip to content

Commit

Permalink
refactor: use checkVisibility when supported by browser
Browse files Browse the repository at this point in the history
  • Loading branch information
vursen committed Feb 21, 2025
1 parent 130ef3b commit 311f2d0
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions packages/a11y-base/src/focus-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,13 @@ function sortElementsByTabIndex(elements) {
* @return {boolean}
*/
export function isElementHidden(element) {
if (element.checkVisibility) {
return !element.checkVisibility();
}

// TODO: checkVisibility is supported only from Safari 17.4, so we still need to
// keep the custom implementation as a fallback for older versions until Vaadin 25:

// `offsetParent` is `null` when the element itself
// or one of its ancestors is hidden with `display: none`.
// https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetParent
Expand Down

0 comments on commit 311f2d0

Please sign in to comment.