Determines if an element has any relevance to focus management.
This module is a pre-filter for
ally.get.focusRedirectTarget. Elements may be considered focus-relevant, even though they do not in fact be focusable, tabbable, only-tabbable or redirect focus given their current conditions. But any element that is focusable, tabbable, only-tabbable or redirects focus is focus-relevant.
var element = document.getElementById('victim'); var isFocusRelevant = ally.is.focusRelevant(element);
||required||The Element to test.|
The underlying rules can also be accessed in the
options argument style by calling
||required||The element to examine. The first element of a collection is used.|
||The Element to test.|
true if the element is focus relevant.
element argument is not of type
<keygen>elements are considered focus-relevant, but not focusable.
element.prototype.matchespolyfill is re-applied to allow elements from other documents (e.g. from an iframe).
<object>element properly distinguishes between SVG and SWF content.
v1.1.0elements using Flexbox layout are properly identified in IE10 and IE11.
v1.1.0the ShadowDOM hosts are considered focus-relevant, but not focusable.
v1.1.0scrollable containers are properly identified in Internet Explorer.
<area>elements are considered focus-relevant.
v1.1.0every element that is either focusable, keyboard focusable, only tabbable or redirects focus is considered focus-relevant.
v1.1.0exceptions can be passed to
v1.1.0IE9 properly resolves SVG links (
element.prototype.matcheswas replaced by
v1.4.0SVG elements with
tabindex="-1"are handled properly in Firefox 51 (Bug 1302340) as well as MS Edge 14.
v1.4.0only Blink considers
<use … tabindex="-1">focus relevant.
v1.4.0only Blink and WebKit consider
<foreignObject … tabindex="-1">focus relevant.
v1.4.0the document element (
<svg>) of SVG documents in browsing contexts (
<object>) is considered focus relevant in Firefox 51.
<body> element may mistakenly considered focusable, because it is the default activeElement if no other element has focus - but it is not focusable, unless made so by adding the
<keygen> element is poorly supported, practically never used and has seen intent to deprecate, ally considers all
<keygen> elements focus-relevant but not focusable.
Because the behavior of the
<embed> element depends on the content type and browser plugin, ally considers all
<embed> elements focus-relevant but not focusable.
Internet Explorer 9 supports VML (which was dropped in IE10 in favor of SVG), which allows linking using the
href attribute. Ally.js does not understand VML because it does not exist in modern browsers anymore.
Firefox and Internet Explorer cannot focus
SVGElements by script, thus no SVG element is considered focusable, see Gecko 1116966.
# Related resources
ally.is.focusabletests focus-relevant elements if they're also visible and not disabled
ally.is.tabbabletests elements if they're keyboard focusable
ally.is.validTabindexis used to verify the element's
tabindexvalue is valid
ally.query.focusablefinds focusable elements in the DOM