Skip to content

Latest commit

 

History

History
executable file
·
189 lines (139 loc) · 6.44 KB

File metadata and controls

executable file
·
189 lines (139 loc) · 6.44 KB
id 674b10
name Role attribute has valid value
rules_format 1.1
rule_type atomic
description This rule checks that each `role` attribute has a valid value.
accessibility_requirements
wcag-technique:ARIA4 wcag-technique:G108 wcag20:1.3.1 wcag20:4.1.2
forConformance failed passed inapplicable
false
not satisfied
further testing needed
further testing needed
forConformance failed passed inapplicable
false
not satisfied
further testing needed
further testing needed
secondary
This success criterion is **less strict** than this rule. This is because the success criterion can be satisfied by an element's implicit role when the explicit role is incorrect. Some of the failed examples may satisfy this success criterion.
secondary
This success criterion is **less strict** than this rule. This is because the success criterion can be satisfied by an element's implicit role when the explicit role is incorrect. Some of the failed examples may satisfy this success criterion.
input_aspects
DOM Tree
CSS Styling
acknowledgments
authors funding
Jey Nandakumar
WAI-Tools

Applicability

This rule applies to any role attribute for which all the following are true:

Expectation

Each test target has at least one token which is a valid value corresponding to a non-abstract role from WAI-ARIA Specifications.

Background

Using an invalid role is often the result of a typo or other developer error. Unknown roles are ignored by browsers and assistive technologies, and the element's implicit role is used. This often means that a role that should exist is missing.

The role attribute is a set of space separated tokens. Having a whitespace separated list of more than one token in the value of the role attribute is used for what is known as fallback roles. If the first token is not accessibility supported (or valid), the next one will be used for determining the semantic role of the element, and so forth. The rule applies to attributes containing at least one non-ASCII whitespace character so that there is at least one token in the set.

Not every role can be used on every element. Which ARIA roles may be used on which HTML elements is defined in ARIA in HTML. Testing this is not part of this rule.

Assumptions

There are no assumptions.

Accessibility Support

There are no accessibility support issues known.

Other Resources

Examples

Passed

Passed Example 1

This role attribute contains one searchbox token which is a valid WAI-ARIA role.

<label>Search: <input type="text" role="searchbox" placeholder="Enter 3 or more characters"/></label>

Passed Example 2

This role attribute contains two tokens which are both valid WAI-ARIA roles.

<style>
	.ref {
		color: #0000ee;
		text-decoration: underline;
		cursor: pointer;
	}
</style>
See [<span class="ref" onclick="location.href='https://act-rules.github.io/'" role="doc-biblioref link">ACT rules</span
>].

Passed Example 3

This role attribute contains two tokens, and one of these tokens (searchbox) is a valid WAI-ARIA role.

<label>Search: <input type="text" role="searchfield searchbox" placeholder="Enter 3 or more characters"/></label>

Failed

Failed Example 1

This role attribute contains one lnik token, but this token is not a valid role in any of the WAI-ARIA specifications.

<style>
	.link {
		color: #0000ee;
		text-decoration: underline;
		cursor: pointer;
	}
</style>
I love <span class="link" onclick="location.href='https://act-rules.github.io/'" role="lnik">ACT rules</span>.

Failed Example 2

This role attribute contains two tokens, but neither of these tokens is a valid role in any of the WAI-ARIA specifications.

<style>
	.ref {
		color: #0000ee;
		text-decoration: underline;
		cursor: pointer;
	}
</style>
See [<span class="ref" onclick="location.href='https://act-rules.github.io/'" role="bibliographic-reference lnik"
	>ACT rules</span
>].

Inapplicable

Inapplicable Example 1

There is no role attribute.

<img src="/test-assets/shared/w3c-logo.png" alt="W3C logo" />

Inapplicable Example 2

This role attribute has no value.

<div role>Some Content</div>

Inapplicable Example 3

This role attribute is empty ("").

<div role="">Some Content</div>

Inapplicable Example 4

This role attribute is only ASCII whitespace.

<input type="text" role=" " aria-label="field name" />

Inapplicable Example 5

This role attribute is specified on an element which is programmatically hidden.

<div aria-hidden="true" role="banner">Some Content</div>