# ally.is.visible
Determines if an element is rendered.
# Description
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.
# Usage
var element = document.getElementById('victim');
var isVisible = ally.is.visible(element);
# Arguments
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. |
# Returns
Boolean, true
if the element is visible (i.e. not hidden by CSS).
# Throws
TypeError
if element
argument is not of type HTMLElement
.
# Changes
- 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.
# Notes
<area>
elements are not rendered by themselves, so they are always considered visible.