Skip to content

ARIA IDL updates: enumerated attribute conversions, new "enumerated" wai-aria type, IDL examples #2484

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

Open
wants to merge 18 commits into
base: main
Choose a base branch
from

Conversation

rahimabdi
Copy link
Contributor

@rahimabdi rahimabdi commented Mar 23, 2025

Closes #2281
Closes #2279

If helpful, I also created this tool to simulate how the new ARIA IDL works for enumerated attributes: https://rahimabdi.github.io/aria-idl-simulator/.

  • add enumerated attribute definitions for the following attributes including missing value default, invalid value default, keywords/states:
    • aria-atomic
    • aria-autocomplete
    • aria-busy
    • aria-checked
    • aria-current
    • aria-disabled
    • aria-expanded
    • aria-haspopup
    • aria-hidden
    • aria-invalid
    • aria-live
    • aria-modal
    • aria-multiline
    • aria-multiselectable
    • aria-orientation
    • aria-pressed
    • aria-readonly
    • aria-required
    • aria-selected
    • aria-sort
  • Revise "A. Mapping WAI-ARIA Value types to languages" to include enumerated attributes
  • Revise "6.2.4 Value" for permissible values (remove all other types except "enumerated"?)
  • Update "6.3 ARIA Attributes"
    • Remove obsolete note in "6.3.4 ARIA nullable DOMString Attributes" about ARIA transitioning to non-nullable DOMString?
    • Remote spec guidance around getting/setting to only apply to non-enumerated attributes
    • Provide updated examples for "6.3.4.1 Example Attribute Usage"
  • Visual styling
    • Remove <strong> style from old "defaults" values
    • Confirm and apply style for new “State” column, state descriptions

Test, Documentation and Implementation tracking

Once this PR has been reviewed and has consensus from the working group, tests should be written and issues should be opened on browsers. Add N/A and check when not applicable.

  • "author MUST" tests:
  • "user agent MUST" tests:
  • Browser implementations (link to issue or commit):
    • WebKit:
    • Gecko:
    • Blink:
  • Does this need AT implementations?
  • Related APG Issue/PR:
  • MDN Issue/PR:

Preview | Diff

Copy link

netlify bot commented Mar 23, 2025

Deploy Preview for wai-aria ready!

Name Link
🔨 Latest commit b2ba05c
🔍 Latest deploy log https://app.netlify.com/sites/wai-aria/deploys/680e623f1c81250008bd9810
😎 Deploy Preview https://deploy-preview-2484--wai-aria.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

index.html Outdated
<td class="value-description">The element does not support being checked.</td>
</tr>
</tbody>
</table>
<p>The attribute's <a data-cite="html/common-microsyntaxes.html#missing-value-default">missing value default</a> and <a data-cite="html/common-microsyntaxes.html#invalid-value-default">invalid value default</a> are both the Undefined state.</p>
Copy link
Contributor Author

@rahimabdi rahimabdi Mar 23, 2025

Choose a reason for hiding this comment

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

Migrated comment from @keithamus (original):

I don't think we want the missing value default here to return the Undefined state, that will mean the .ariaChecked property will return "undefined" when aria-checked isn't on the element. I presume we want to return null instead? Browsers currently return null, so missing should be "no state", i.e. removed:

Suggested change
<p>The attribute's <a data-cite="html/common-microsyntaxes.html#missing-value-default">missing value default</a> and <a data-cite="html/common-microsyntaxes.html#invalid-value-default">invalid value default</a> are both the Undefined state.</p>
<p>The attribute has no <a data-cite="html/common-microsyntaxes.html#missing-value-default">missing value default</a> and its <a data-cite="html/common-microsyntaxes.html#invalid-value-default">invalid value default</a> is the Undefined state.</p>

@rahimabdi
Copy link
Contributor Author

@keithamus:

@rahimabdi I've left a couple of review notes which I think apply in a lot of places, but rather than inundating you with review comments hopefully you can take the couple here and pattern match across the rest of the spec.

Thanks! I'll review those comments (which are migrated to this PR now) and respond.

@rahimabdi
Copy link
Contributor Author

Re-added reviewers @pkra @spectranaut @cookiecrook @keithamus @scottaohara.

@rahimabdi rahimabdi marked this pull request as draft March 27, 2025 17:23
@rahimabdi rahimabdi marked this pull request as ready for review April 27, 2025 17:03
@rahimabdi
Copy link
Contributor Author

rahimabdi commented Apr 27, 2025

CC @pkra @spectranaut @cookiecrook @keithamus @scottaohara @annevk

This PR is ready for review! I've made a number of updates, mainly:

  • Cleaned up enumerated attribute keywords/states per @keithamus's feedback
  • Changed aria-atomic's Missing state to Undefined, to align with other ARIA attributes that have an "Undefined" state
  • Added more IDL usage examples
  • Added a note clarifying that Undefined state is equivalent to "no state"

If helpful, I also created this tool to simulate how the new ARIA IDL works for enumerated attributes: https://rahimabdi.github.io/aria-idl-simulator/.

@rahimabdi rahimabdi requested review from keithamus, annevk, cookiecrook, pkra, spectranaut and scottaohara and removed request for annevk April 27, 2025 17:08
Copy link
Member

@annevk annevk left a comment

Choose a reason for hiding this comment

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

One thing that's nice in HTML is that all the states are a <dfn> and therefore also can be linked. But maybe that's best addressed in a follow-up.

Comment on lines +11941 to +11942
Some ARIA attributes support an Undefined state, which is equivalent to having no state (i.e., null). User agent implementations may omit the Undefined state since the lack of an explicit
state results in the same behavior. For more information about determining the state of enumerated attributes, see
Copy link
Member

Choose a reason for hiding this comment

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

I think this sentence adds more confusion than it resolves. Especially since you cannot just leave it out at the moment without hitting an assert.

Default values from the ARIA values tables MUST NOT reflect to IDL as the <a data-cite="html/common-microsyntaxes.html#missing-value-default">missing value default</a> or the
<a data-cite="html/common-microsyntaxes.html#invalid-value-default">invalid value default</a> for the attribute. On getting, a missing ARIA attribute will return <code>null</code>. ARIA
attributes are not validated on get. If an ARIA value is invalid, on getting, it will return its set value as a literal string, and will not return an invalid value default.
For non-enumerated attributes, default values from the ARIA values tables MUST NOT reflect to IDL as the
Copy link
Member

Choose a reason for hiding this comment

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

This seems okay to state as a note, but it shouldn't be a requirement. HTML already requires this.

@@ -12761,7 +12802,7 @@ <h2>Definitions of States and Properties (all aria-* attributes)</h2>
</tr>
<tr>
<th class="state-value-head" scope="row">Value:</th>
<td class="state-value"><a href="#valuetype_tristate">tristate</a></td>
<a href="#valuetype_enumerated">enumerated</a>
Copy link
Member

Choose a reason for hiding this comment

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

This seems better

Suggested change
<a href="#valuetype_enumerated">enumerated</a>
<td class="state-value"><a href="#valuetype_enumerated">enumerated</a></td>

@cyns
Copy link
Contributor

cyns commented May 8, 2025

@aleventhal you may want to review this

@cyns cyns self-requested a review May 8, 2025 17:40
<td class="value-description">
When a user is providing input, an element containing a collection of values that could complete the provided input might be displayed. If displayed, one value in the collection is
automatically selected, and the text needed to complete the automatically selected value appears after the caret in the input.
</td>
</tr>
<tr>
<th class="value-name" scope="row"><strong class="default">none (default)</strong></th>
<th class="value-name" scope="row">none</th>
Copy link
Member

Choose a reason for hiding this comment

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

Is it intentional that (default) is dropped here? (And in 18 other instances.)

@spectranaut
Copy link
Contributor

Discussed in today's meeting: https://www.w3.org/2025/05/08-aria-minutes.html#7d9a

Copy link
Contributor

@cyns cyns left a comment

Choose a reason for hiding this comment

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

lgtm! this is much more clear, thank you

<p>
For <a data-cite="html/common-dom-interfaces.html#reflect">reflection</a> purposes, the attribute's
<a data-cite="html/common-microsyntaxes.html#missing-value-default">missing value default</a> is the Undefined state (null) that has no associated keyword, and its
<a data-cite="html/common-microsyntaxes.html#invalid-value-default">invalid value default</a> is the False state.
Copy link
Member

@keithamus keithamus May 12, 2025

Choose a reason for hiding this comment

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

(Blocking) So I believe this kind of change to the spec is web observable, which means it will need changes to the implementations and we need to ensure compatibility for web developers who may depend on the existing behaviour. Unless I am missing that somewhere we clarify that reflected enumerated properties should only return the value of the content attribute?

In this example the web observable piece is that the "invalid value default" is the False state, which means that any invalid value would map to the False (for which I presume the keyword is "false" - see above).

This means pasting this HTML into your URL bar:

data:text/html,<body id=b><div id=d aria-atomic=foo><script>b.append(d.ariaAtomic)</script>

Should render false on the page. But right now it renders foo.

I think this will be the same for all of these properties, e.g. aria-autocomplete, aria-checked and so on.

Copy link
Member

Choose a reason for hiding this comment

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

Right, we should have tests for this and such, but this is very much the motivation for making this change. This makes these IDL attributes more meaningful and enables them to be used for feature testing going forward.

Copy link
Member

Choose a reason for hiding this comment

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

For sure, I appreciate the motivation for it, I just want us to be cautious about introducing changes to the spec without getting tests & approval from the various engines.

<td class="value-description">The element is checked.</td>
</tr>
<tr>
<th class="value-name" scope="row"><strong class="default">undefined</strong> (default)</th>
<th class="value-name" scope="row">undefined, empty string ("")</th>
Copy link
Member

@keithamus keithamus May 12, 2025

Choose a reason for hiding this comment

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

(Non-blocking) We could reasonably drop the undefined keyword here:

Suggested change
<th class="value-name" scope="row">undefined, empty string ("")</th>
<th class="value-name" scope="row">empty string ("")</th>

If someone set "undefined" then it would map to the invalid value default, which is the undefined state. The only reason not to do this is if you want the canonicalization steps to explicitly return undefined rather than the empty string.

The same is true for other properties, e.g. aria-current, and so on.

@spectranaut spectranaut moved this from All PRS to Needs Consensus/Review in ARIA Normative PR Tracking Jun 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Needs Review
6 participants