-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add definition for implicit/explicit ARIA attributes #2154
base: develop
Are you sure you want to change the base?
Changes from 11 commits
593ab3d
07a1a6e
6fe0f13
41324e8
0571507
b3e4099
0cf36b4
a18afec
1e1fa47
a44c668
4f135b6
1e54b3e
bb7e66b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,40 @@ | ||||||
--- | ||||||
title: ARIA state or property is set | ||||||
key: aria-attribute-set | ||||||
unambiguous: true | ||||||
objective: true | ||||||
input_aspects: | ||||||
- Accessibility tree | ||||||
- CSS styling | ||||||
- DOM tree | ||||||
--- | ||||||
|
||||||
An ARIA [state][aria state] or [property][aria property] is <dfn>set</dfn> on an [HTML element][namespaced element] when it has a value. This may happen in three ways: | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The term "value" brings to mind the explicit value of an attribute. What if we replace it with "when the accessibility tree exposes its value." There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This proved tricky, especially in combination of #2154 (comment) 😅 TLDR: DOM/HTML define the "value" of an attribute as the stuff written in the HTML code, which differs from our "attribute value", making everything hard to write. Here, we want to refer to the "value as written" since, presumably, the incorrect values could be dropped by parsing/validation and thus not make it to the "attribute value". Plus, as @carlosapaduarte stated, we do want rules to validate the "value as written" and thus not really bake it into this definition Anyway, I tried to improve the situation… |
||||||
|
||||||
- It is <dfn id="aria-attribute-set:explicit">explicitly set</dfn> if there is a corresponding `aria-*` HTML attribute on the element. If the [value][html attribute value] as written in the HTML code is not valid for this ARIA [state][aria state] or [property][aria property] and then the attribute is set but does not have an [attribute value][]. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
For example, `aria-label` is explicitly set on `<button aria-label="Next page">Next</button>`; and `aria-checked` is explicitly set on `<input type="checkbox" aria-checked="yes" />`, even though it does not have an [attribute value][]. | ||||||
|
||||||
- It is <dfn id="aria-attribute-set:implicit">implicitly set</dfn> if there is no corresponding `aria-*` HTML attribute on the element, but the element or one of its HTML attribute has an [ARIA attribute mapping][aria attribute mapping] setting this ARIA attribute. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
For example, `aria-checked` is implicitly set both on `<input type="checkbox" checked />` (through the [presence of the HTML attribute `checked`][checked present]) and `<input type="checkbox" />` (through its [absence][checked absent]). It is not set on `<input type="text" />` given that the mapping for `checked` doesn't apply when the `input` element is not of type `checkbox` or `radio`. | ||||||
|
||||||
- It is <dfn id="aria-attribute-set:default">set by default</dfn> if there is no corresponding `aria-*` HTML attribute on the element, and either the element has an [semantic role][] that has a default value for this ARIA [state][aria state] or [property][aria property] or the attribute itself has a default value. | ||||||
|
||||||
For example, `aria-haspopup` is set by default on `<div role="combobox"></div>` through the role of `combobox`. | ||||||
|
||||||
#### Background | ||||||
|
||||||
For explicitly set attributes, this definition only looks at the value written in the HTML code, without considering its validity. Attributes that are explicitly set with an invalid value are author errors that are detected by the rule [Role attribute has valid value](https://www.w3.org/WAI/standards-guidelines/act/rules/674b10/), and authors should not rely on invalid value to have forbidden attributes discarded from roles not allowing it. | ||||||
|
||||||
For attributes set by default, this definition doesn't consider whether the attribute is allowed on the element (or role). Thus, `aria-expanded` (whose default value is `false`) is considered as set by default on `<input />` even though it is not allowed on the `textbox` role. While authors can (and should) rely on attributes to be set by default, they also have no direct control on them and therefore whether they are allowed on an element never causes an author error. | ||||||
|
||||||
[aria attribute mapping]: https://www.w3.org/TR/html-aam-1.0/#html-attribute-state-and-property-mappings 'HTML Attribute State and Property Mappings' | ||||||
[aria property]: https://www.w3.org/TR/wai-aria-1.2/#dfn-property 'Definition of ARIA Property' | ||||||
[aria state]: https://www.w3.org/TR/wai-aria-1.2/#dfn-state 'Definition of ARIA State' | ||||||
[attribute value]: #attribute-value 'Definition of Attribute Value' | ||||||
[checked absent]: https://www.w3.org/TR/html-aam-1.0/#att-checked-absent 'HTML Accessibility API Mappings, Attribute Checked absent' | ||||||
[checked present]: https://www.w3.org/TR/html-aam-1.0/#att-checked 'HTML Accessibility API Mappings, Attribute Checked present' | ||||||
[html attribute value]: https://html.spec.whatwg.org/multipage/dom.html#attributes 'HTML Specification of Attribute Value' | ||||||
[namespaced element]: #namespaced-element 'Definition of Namespaced Element' | ||||||
[semantic role]: #semantic-role 'Definition of Semantic Role' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would this not still be a responsibility of the author to ensure the attributes are correct? It could still lead to violations, does the ARIA state or property has valid value check for this? If so, I think we should just call that out directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If only it was so simple 😞
<input type="checkbox" role="button" aria-pressed="false" />
is allowed by ARIA (as far as I can tell), but has an implicitaria-checked
set bychecked
(automagically set on<input type="checkbox" />
), which is not allowed on a role ofbutton
…