← Back to release summary

Element.checkVisibility method

Category
DOM
Type
New or changed feature
Status
Enabled by default (Chrome 105)
Intent stage
Prepare to ship

Summary

Element.checkVisibility() returns true if the element is visible, and false if it is not. It checks a variety of factors that would make an element invisible, including display:none, visibility, content-visibility, and opacity.

Motivation

With the addition of content-visibility, there are now several different ways to hide an element. This new method accounts for all of these and can look at state script in the page can't see, such as content-visibility:hidden in the user agent shadow DOM of a closed details element.

Standards & signals

Explainers: https://github.com/WICG/display-locking/blob/main/explainers/isvisible.md

View on chromestatus.com