-
Notifications
You must be signed in to change notification settings - Fork 75
Add definition for implicit/explicit ARIA attributes #2154
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
base: develop
Are you sure you want to change the base?
Conversation
- 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 comment
The 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 comment
The 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…
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.
In addition to Giacomo's comments, I've added some more.
pages/glossary/aria-attribute-set.md
Outdated
|
||
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: | ||
|
||
- It is <dfn id="aria-attribute-set:explicit">explicitly set</dfn> if there is a corresponding `aria-*` HTML attribute on the element, whose value is valid for this ARIA [state][aria state] or [property][aria property]. |
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.
"whose value is valid for this ARIA state or property"
Shouldn't this be checked by ARIA state or property has valid value?
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.
See #2154 (comment)
pages/glossary/aria-attribute-set.md
Outdated
|
||
For example, `aria-checked` is implicitly set on `<input type="checkbox" checked />`. | ||
|
||
- It is <dfn id="aria-attribute-set:default">set by default</dfn> if there is no corresponding `aria-*` HTML attribute on the element, and the element has an [implicit semantic role][implicit role] that has a default value for this ARIA [state][aria state] or [property][aria property]. |
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.
It is really hard to differentiate between implicitly set and set by default according to these definitions (the later is a subset of the former). Do we really need two definitions? Can we just have explicitly and implicitly set in the "Element with role attribute has required states and properties" rule?
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.
Indeed, definition was a bit weak. I do believe these are still different and it might be valuable to be able to speak about one or the other (maybe not immediately, though…)
I improved the definition to make the difference more obvious. It is still a bit of a weak difference (depends which specs is setting it, essentially…) 🤷
Carlos Duarte seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
@@ -64,6 +64,8 @@ The presence of prohibited ARIA attributes is often the result of a developer us | |||
|
|||
In HTML, there are language features that do not have corresponding implicit WAI-ARIA semantics. As per [ARIA in HTML](https://www.w3.org/TR/html-aria/), those elements can have [global states or properties][global]. Some of those elements can also have [inherited][], [supported][], or [required][] [states][state] or [properties][property] that correspond to a [WAI-ARIA role](https://www.w3.org/TR/wai-aria-1.2/#introroles). For example, the `audio` element has no corresponding ARIA semantics but it can have [inherited][], [supported][], or [required][] [states][state] or [properties][property] of the [`application` role](https://www.w3.org/TR/wai-aria-1.2/#application). | |||
|
|||
This rule only applies to [explicitly set][aria set explicit] attributes since these have been provided by authors and using the wrong one is therefore an author issue. If an [implicitly set][aria set implicit] attribute is incorrect, this is not necessarily an author error, e.g., it can be the result of re-purposing an existing element. |
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 implicit aria-checked
set by checked
(automagically set on <input type="checkbox" />
), which is not allowed on a role of button
…
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.
An implicit attribute doesn't show up in the code, rather, it is only added automatically by a user agent during accessibility API mapping. A checker using the rule would never pick up any implicit attribute. Therefore, it's not necessary to call out the implicit attribute for the purpose of a rule.
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.
Minor edits suggested
Co-authored-by: Carlos Duarte <[email protected]>
This `button` does not have any [explicitly set][aria set explicit] ARIA attribute. It has an [implicitly set][aria set implicit] `aria-checked` state, due to the [absence of a `checked` attribute][checked absent] on the `input` element with a `type` [attribute value][] of `checkbox`. | ||
|
||
```html | ||
<input type="checkbox" role="button" /> |
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.
isn't this supposed to be used together with aria-pressed
if role="button" type="checkbox"
? https://www.w3.org/TR/html-aria/#el-input-checkbox
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.
No need to mention the implicit attribute "aria-checked" because it doesn't exist in the code that a checker runs on.
|
||
#### Passed Example 8 | ||
|
||
This `menuitemcheckbox` has its required `aria-checked` property [implicitly set][aria set implicit]. |
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.
This `menuitemcheckbox` has its required `aria-checked` property [implicitly set][aria set implicit]. | |
This `menuitemcheckbox` has its required `aria-checked` property [implicitly set][aria set implicit] because type="checkbox" is set on the element. |
If I am correctly understanding, aria-checked
is only set because of type="checkbox"
? Should this be clarified and then a failed example created (if we don't have one already)?
This menuitemcheckbox
does not have its required aria-checked
property [implicitly set][aria set implicit].
<label>
<input role="menuitemcheckbox" />
Check me
</label>
|
||
#### Passed Example 9 | ||
|
||
This `iframe` element is [included in the accessibility tree][], even without a role, and therefore has no [WAI-ARIA required states and properties][]. |
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.
trying to figure out this example, is it to clarify that role
is not a requirement for this rule as long as other required properties are set (if the element is in the accessibility tree)?
|
||
```html | ||
<div>Some Content</div> | ||
``` | ||
|
||
#### Inapplicable Example 2 | ||
|
||
This `checkbox` has an [implicit semantic role](#implicit-role) that is identical to the [explicit semantic role](#explicit-role). This allows native HTML `checked` attribute to apply. |
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.
can you explain why this was removed?
|
||
- 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] written in the HTML code is not valid for this ARIA [state][aria state] or [property][aria property] then the attribute is set but does not have an [attribute value][]. | ||
|
||
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][]. |
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.
just wondering if it would be better to use a different example for <input type="checkbox" aria-checked="yes" />
since these attributes generally shouldn't be used together and the value of checked
will be false
on the accessibility tree
@@ -64,6 +64,8 @@ The presence of prohibited ARIA attributes is often the result of a developer us | |||
|
|||
In HTML, there are language features that do not have corresponding implicit WAI-ARIA semantics. As per [ARIA in HTML](https://www.w3.org/TR/html-aria/), those elements can have [global states or properties][global]. Some of those elements can also have [inherited][], [supported][], or [required][] [states][state] or [properties][property] that correspond to a [WAI-ARIA role](https://www.w3.org/TR/wai-aria-1.2/#introroles). For example, the `audio` element has no corresponding ARIA semantics but it can have [inherited][], [supported][], or [required][] [states][state] or [properties][property] of the [`application` role](https://www.w3.org/TR/wai-aria-1.2/#application). | |||
|
|||
This rule only applies to [explicitly set][aria set explicit] attributes since these have been provided by authors and using the wrong one is therefore an author issue. If an [implicitly set][aria set implicit] attribute is incorrect, this is not necessarily an author error, e.g., it can be the result of re-purposing an existing element. |
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.
An implicit attribute doesn't show up in the code, rather, it is only added automatically by a user agent during accessibility API mapping. A checker using the rule would never pick up any implicit attribute. Therefore, it's not necessary to call out the implicit attribute for the purpose of a rule.
This `button` does not have any [explicitly set][aria set explicit] ARIA attribute. It has an [implicitly set][aria set implicit] `aria-checked` state, due to the [absence of a `checked` attribute][checked absent] on the `input` element with a `type` [attribute value][] of `checkbox`. | ||
|
||
```html | ||
<input type="checkbox" role="button" /> |
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.
No need to mention the implicit attribute "aria-checked" because it doesn't exist in the code that a checker runs on.
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][]. | ||
For each test target, the [WAI-ARIA required states and properties][] for the role are [set][aria set] and not empty (`""`). | ||
|
||
The attributes may be [explicitly set][aria set explicit], [implicitly set][aria set implicit], or [set by default][aria set default]. | ||
|
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.
same with my early comment, an implicit attribute doesn't show up in the code, and thus never picks up by a checker, so it's not necessary to include any implicit attribute.
aria-*
attribute, an implicit HTML AAM, or a default value.aria-*
HTML attributes, this makes it a bit clearer.Closes issue(s):
Need for Call for Review:
This will require a 2 weeks Call for Review (significant changes to Applicability)
Pull Request Etiquette
When creating PR:
develop
branch (left side).After creating PR:
Rule
,Definition
orChore
.When merging a PR:
How to Review And Approve