layout | tags |
---|---|
doc-api.html |
argument-list |
Determines if an element is rendered.
An element is considered visible if it satisfies all of the following rules:
- Neither the element nor an element of its ancestry has
display: none;
applied. - Neither the element nor an element of its ancestry has
visibility: hidden;
applied, unless a closer relative in the ancestry reverts that directive by definingvisibility: visible
. - The element is not a descendant of a collapsed
<details>
element. - The element is not hosted in an
<object>
or<iframe>
element that is considered invisible byally.is.visible
An element can be visible, but not visible within the viewport.
var element = document.getElementById('victim');
var isVisible = ally.is.visible(element);
Name | Type | Default | Description |
---|---|---|---|
element | HTMLElement |
required | The Element to test. |
The underlying rules can also be accessed in the options
argument style by calling ally.is.visible.rules(options)
:
Name | Type | Default | Description |
---|---|---|---|
context | <selector> |
required | The element to examine. The first element of a collection is used. |
except | <focus identification exception> |
{} |
The Element to test. |
Boolean, true
if the element is visible (i.e. not hidden by CSS).
TypeError
if element
argument is not of type HTMLElement
.
- Since
v1.1.0
exceptions can be passed toally.is.visible.rules(options)
. - Since
v1.1.0
the state of the hosting<iframe>
or<object>
element is considered.
:::note
<area>
elements are not rendered by themselves, so they are always considered visible.
:::