Audit aria-required-attr
Ensure elements with ARIA roles have all required ARIA attributes
Impact:
WCAG-Konformität:
- AWCAG 4.1.2
Issue type:
failureElement with role attribute has required states and properties
This rule checks that elements that have an explicit role also specify all required states and properties.
Applicability
This rule applies to any HTML or SVG element that is included in the accessibility tree and has an explicit semantic role, except if the element has an implicit semantic role that is identical to the explicit semantic role.
Expectation
For each test target, the WAI-ARIA required states and properties for the role are set and not empty (""
), unless the state or property has a default value listed under WAI-ARIA implicit value for role.
Background
Omitting WAI-ARIA required states and properties is often the result of a developer error. When required properties are missing and a default value is not specified by WAI-ARIA Specifications, the behavior is not defined. For WAI-ARIA 1.2, the only explicit semantic roles with a required property with a default value are the option
and tabs roles
for the aria-selected
property.
This rule is testing author built components that specify explicit semantic roles and not components that keep their implicit semantic role. For components that keep their implicit semantic role, all native HTML and SVG elements have native attributes that are mapped to all of the WAI-ARIA required states and properties. Most of these mappings are defined in the HTML Accessibility API Mappings, Attribute State and Property Mappings.
Assumptions
- The ARIA
role
is being used to conform to WCAG.
Accessibility Support
This rule relies on browsers and assistive technologies to support leaving out WAI-ARIA required states and properties when a WAI-ARIA implicit value for role is specified in WAI-ARIA Specifications.
Note: The required states and properties with implicit values can be found in the Core Accessibility API Mappings 1.1 Overview of default values for missing required attributes.
Bibliography
- ARIA5: Using WAI-ARIA state and property attributes to expose the state of a user interface component
- WAI-ARIA required states and properties
- RFC 3986
Test Cases
Passed
Passed Example 1
This heading
has the required aria-level
property.
<div role="heading" aria-level="1">
My First Heading
</div>
Passed Example 2
This checkbox
has the required aria-checked
property.
<div role="checkbox" aria-checked="false" aria-labelledby="label"></div>
<div id="label">Check me</div>
Passed Example 3
This scrollbar
has the required properties aria-controls
and aria-valuenow
. aria-valuemin
has a default value of 0 and aria-valuemax
of 100.
<div role="scrollbar" aria-controls="content" aria-valuenow="0"></div>
<main id="content"></main>
Passed Example 4
These option
nodes do not need the required aria-selected
property because it has a default value of false
.
<div id="label">Tags</div>
<ul role="listbox" aria-labelledby="label">
<li role="option">Zebra</li>
<li role="option">Zoom</li>
</ul>
Passed Example 5
This separator
is not a widget
because it is not focusable. The separator
role only requires the aria-valuenow
property when the element is focusable.
<p>My first HTML</p>
<div role="separator"></div>
<p>My last HTML</p>
Passed Example 6
This combobox
has the required properties aria-controls
and aria-expanded
.
<label for="tag_combo">Tag</label>
<input type="text" id="tag_combo" role="combobox" aria-expanded="true" aria-controls="popup_listbox" />
<ul role="listbox" id="popup_listbox">
<li role="option">Zebra</li>
<li role="option" id="selected_option">Zoom</li>
</ul>
Failed
Failed Example 1
This heading
does not have the required aria-level
property. Prior to WAI-ARIA 1.2 the heading
role had an implicit default aria-level
value of 2
. As of WAI-ARIA 1.2 this property must be explicitly set.
<div role="heading">
My First Heading
</div>
Failed Example 2
This switch
does not have the required aria-checked
property. Prior to WAI-ARIA 1.2 the switch
role had an implicit default aria-checked
value of false
. As of WAI-ARIA 1.2 this property must be explicitly set.
<div role="switch">
Toggle me
</div>
Failed Example 3
This checkbox
does not have the required property aria-checked
. Prior to WAI-ARIA 1.2 the checkbox
had an implicit default aria-checked
value of false
. As of WAI-ARIA 1.2 this property must be explicitly set.
<div role="checkbox" aria-labelledby="label"></div>
<div id="label">Check me</div>
Failed Example 4
This separator
does not have the required aria-valuenow
property. This is required because the separator
is focusable, which makes it a widget
.
<p>My first HTML</p>
<div role="separator" tabindex="0"></div>
<p>My last HTML</p>
Failed Example 5
This combobox
does not have the required aria-expanded
property. Prior to WAI-ARIA 1.2 the combobox
had an implicit default aria-expanded
value of false
. As of WAI-ARIA 1.2 this property must be explicitly set.
<label for="tag_combo">Tag</label>
<input type="text" id="tag_combo" role="combobox" aria-controls="popup_listbox" />
<ul role="listbox" id="popup_listbox">
<li role="option">Zebra</li>
<li role="option" id="selected_option">Zoom</li>
</ul>
Failed Example 6
This combobox
uses aria-owns
instead of using the required aria-controls
property.
<label for="tag_combo">Tag</label>
<input type="text" id="tag_combo" role="combobox" aria-expanded="true" aria-owns="popup_listbox" />
<ul role="listbox" id="popup_listbox">
<li role="option">Zebra</li>
<li role="option" id="selected_option">Zoom</li>
</ul>
Inapplicable
Inapplicable Example 1
This div
does not have a semantic role.
<div>Some Content</div>
Inapplicable Example 2
This checkbox
has an implicit semantic role that is identical to the explicit semantic role. This allows native HTML checked
attribute to apply.
<input type="checkbox" role="checkbox" />
Inapplicable Example 3
This combobox
is not included in the accessibility tree due to its styling, hiding it from everybody.
<div role="combobox" style="display:none;"></div>
Autoren: Anne Thyme Nørregaard, Tom Brunet
Finanzierung: WAI-Tools