ally.is.disabled
September 28, 2016 ยท View on GitHub
Determines if an element is :disabled, or was disabled by ally.element.disabled - i.e. the element is not focusable and editable.
Description
Only form controls (<input>, <select>, <textarea>, <button>) and the <fieldset> element know the disabled attribute. While <fieldset disabled> inherits the disabled state onto descendant form controls, that does not affect the value of the descendant's disabled property. Even the detection of inherited disabled state via the :disabled pseudo does not work reliably cross browser. To make matters worse, Internet Explorer 9 - 11 also support the disabled state for <form> elements, with the same inheritance scheme <fieldset> provides.
Usage
var element = document.getElementById('victim');
var isDisabled = ally.is.disabled(element);
Arguments
| Name | Type | Default | Description |
|---|---|---|---|
| element | HTMLElement | required | The Element to test. |
Returns
Boolean, true if the element is disabled.
Throws
TypeError if element argument is not of type HTMLElement.
Examples
Changes
- Since
v1.1.0the<form disabled>is handled properly in Internet Explorer 9 - 11.
Notes
:::note
The <fieldset> element can be disabled, inheriting the state onto all form elements it contains.
:::
:::note
WebKit and Blink do not properly support disabling <fieldset tabindex="0" disabled> elements themselves, while descendant form elements are properly disabled, see Blink 453847, Webkit 141086.
:::
Related resources
-
ally.element.disabledcan disable any interactive element