Skip to content
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

Open
wants to merge 13 commits into
base: develop
Choose a base branch
from

Conversation

Jym77
Copy link
Collaborator

@Jym77 Jym77 commented Jan 11, 2024

  • Add a definition for "ARIA attribute is set", with variations whether it comes from an explicit aria-* attribute, an implicit HTML AAM, or a default value.
  • Switch "role has all required ARIA attributes" to also apply to implicit roles. These normally have implicitly set attributes (which is why we skipped them initially), and can now be handled by this definition.
  • Switch "role has all required ARIA attributes" to accept attributes set in any way.
  • Switch "ARIA attribute permitted" to only look at explicitly set ones. It was more or less already doing that by looking at 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:

  • Make sure you're requesting to pull a branch (right side) to the develop branch (left side).
  • Make sure you do not remove the "How to Review and Approve" section in your pull request description

After creating PR:

  • Add yourself (and co-authors) as "Assignees" for PR.
  • Add label to indicate if it's a Rule, Definition or Chore.
  • Link the PR to any issue it solves. This will be done automatically by referencing the issue at the top of this comment in the indicated place.
  • Optionally request feedback from anyone in particular by assigning them as "Reviewers".

When merging a PR:

  • Close any issue that the PR resolves. This will happen automatically upon merging if the PR was correctly linked to the issue, e.g. by referencing the issue at the top of this comment.

How to Review And Approve

  • Go to the “Files changed” tab
  • Here you will have the option to leave comments on different lines.
  • Once the review is completed, find the “Review changes” button in the top right, select “Approve” (if you are really confident in the rule) or "Request changes" and click “Submit review”.
  • Make sure to also review the proposed Call for Review period. In case of disagreement, the longer period wins.

@Jym77 Jym77 self-assigned this Jan 11, 2024
@Jym77 Jym77 added Rule Update Use this label for an existing rule that is being updated reviewers wanted labels Jan 11, 2024
- 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:
Copy link
Collaborator

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."

Copy link
Collaborator Author

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…

Copy link
Member

@carlosapaduarte carlosapaduarte left a 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.


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].
Copy link
Member

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?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


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].
Copy link
Member

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?

Copy link
Collaborator Author

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…) 🤷

pages/glossary/aria-attribute-set.md Outdated Show resolved Hide resolved
pages/glossary/aria-attribute-set.md Outdated Show resolved Hide resolved
_rules/aria-state-or-property-permitted-5c01ea.md Outdated Show resolved Hide resolved
@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


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.

@Jym77 Jym77 requested a review from tbostic32 February 29, 2024 13:21
_rules/aria-state-or-property-permitted-5c01ea.md Outdated Show resolved Hide resolved
@@ -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.
Copy link
Collaborator

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.

Copy link
Collaborator Author

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

Copy link
Member

@carlosapaduarte carlosapaduarte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor edits suggested


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. 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][].
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- 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][].
- 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][].

- 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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- 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.
- 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 attributes has an [ARIA attribute mapping][aria attribute mapping] setting this ARIA attribute.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
reviewers wanted Rule Update Use this label for an existing rule that is being updated
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Required states can come from native elements [4e8ab6]
5 participants