Skip to content

Instantly share code, notes, and snippets.

@ZoeBijl
Last active February 17, 2022 22:04
Show Gist options
  • Save ZoeBijl/2b82502951ce3907f7397b42475fc4b3 to your computer and use it in GitHub Desktop.
Save ZoeBijl/2b82502951ce3907f7397b42475fc4b3 to your computer and use it in GitHub Desktop.
Check visibility of component
function isHidden(element) {
let { length } = element.getClientRects()
let visibility = window.getComputedStyle(element).visibility === 'hidden'
let ariaHidden = element.closest('[aria-hidden]') != null
let inert = element.closest('[inert]') != null
let hidden = length === 0 || visibility === true || ariaHidden === true || inert === true
return hidden
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment