Skip to content

Latest commit

 

History

History
79 lines (46 loc) · 2.98 KB

focusable.md

File metadata and controls

79 lines (46 loc) · 2.98 KB
layout tags
doc-api.html
argument-list

ally.is.focusable

Determines if an element is considered focusable.

Description

An element is considered focusable if it is ally.is.focusRelevant, ally.is.visible and not ally.is.disabled.

Consult the data tables what browsers consider focusable and what ally.js fails to consider focusable to learn how HTML elements behave.

Usage

var element = document.getElementById('victim');
var isFocusable = ally.is.focusable(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.focusable.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 focusable.

Throws

TypeError if element argument is not of type HTMLElement.

Examples

Changes

  • Since v1.1.0 all <area> elements are considered focus-relevant, but only valid <area> elements are considered focusable.
  • Since v1.1.0 exceptions can be passed to ally.is.focusable.rules(options).
  • Since v1.1.0 the state of the <iframe> or <object> element in which the currently examined element is hosted in is considered.
  • Since v1.1.0 hidden <object> elements are focusable in Chrome - Blink 586191.

Notes

See ally.is.focusRelevant

Related resources

Contributing