Skip to content

feat(aria/get-aria-value): new function to get aria values of a node - #5109

Merged
straker merged 10 commits into
developfrom
elm-internals-get-aria-value
Jun 8, 2026
Merged

feat(aria/get-aria-value): new function to get aria values of a node#5109
straker merged 10 commits into
developfrom
elm-internals-get-aria-value

Conversation

@straker

@straker straker commented May 18, 2026

Copy link
Copy Markdown
Contributor

The getAriaValue function gets the value from the 3 different locations for aria data (attribute, property, element internals). The function will always return am object of { value: String, source: String } or null. However this is a slight problem when an idref(s) property is used as they return DOM nodes or arrays of such. In order to still report what the value is as a string, the function massages the data into a string by taking the node name of the DOM node as that's probably the easiest way to report it to the user. This would result in something like node.ariaLabelledbyElements = [div, div]; having a value of '[div,div]' instead of '' if we only used the attribute value.

In a separate PR we'll create two functions for resolving idref(s) values into vNodes that should be used 99% of the time instead of getAriaValue. getAriaValue for idref(s) should only be used when reporting the value to the user (such as in aria-validate-attr-value).

Closes: #5042

@straker
straker marked this pull request as ready for review June 2, 2026 21:30
@straker
straker requested a review from a team as a code owner June 2, 2026 21:30
@straker straker changed the title feat(aria/get-aria-value): new function to normalize aria values feat(aria/get-aria-value): new function to get aria values of a node Jun 4, 2026

@chutchins25 chutchins25 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice work — clean three-source resolution and thorough tests. A few questions/suggestions, none blocking. (Verified the two moderate ones against the code: SerialVirtualNode has no actualNode, and the single-node branch only matches HTMLElement.)

Comment thread lib/commons/aria/get-aria-value.js Outdated
Comment thread lib/commons/aria/get-aria-value.js Outdated
Comment thread lib/commons/aria/get-aria-value.js Outdated
Comment thread lib/commons/aria/get-aria-value.js Outdated
Comment thread lib/commons/aria/get-aria-value.js Outdated

@chutchins25 chutchins25 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for adding those additional tests! Looks good to me.

@straker
straker merged commit a7d8f3e into develop Jun 8, 2026
23 of 24 checks passed
@straker
straker deleted the elm-internals-get-aria-value branch June 8, 2026 14:05
straker added a commit that referenced this pull request Jun 10, 2026
…ue (#5136)

Companion to #5109 but replaces `vNode.hasAttr`.

This resulted in finding a bug in Firefox which crashes the browser when
trying to access an empty array set to an idrefs property in element
internals. This is why the Firefox tests are failing (technically
crashing). Filled here
https://bugzilla.mozilla.org/show_bug.cgi?id=2045887.
chutchins25 added a commit that referenced this pull request Jun 10, 2026
Add getAriaIdref and getAriaIdrefs to resolve an ARIA element-reference
attribute, AOM property, or ElementInternals value into virtual nodes,
filtering out disconnected references. This is the leftover idref(s)
resolution from #5109; consumers should use these instead of
getAriaValue for references.

Closes issue #5149
straker added a commit that referenced this pull request Jun 12, 2026
…odes of idrefs (#5151)

A new function that is very similar to `commons.dom.idrefs` function,
but understands handling ARIA idrefs properties and element internals
properties and additionally returns virtual nodes rather than DOM nodes.
This was the leftover work from #5109 to handle idrefs being a string
(attribute) or array of nodes (property).

I also update the `queryShadowFixture` function to allow both `#shadow`
and `#target` ids to exist in the light DOM. I looked at all uses of
`queryShadowFixture` and almost all of them use the `#shadow` in the
light DOM and `#target` in the shadow DOM, though a few rely on
`#target` in the light DOM (but no `#shadow`). The changes prioritize
the order of find things so that `#shadow` is used first as the
container, then `#target` (instead of the other way around) and the
target selector is found in the shadow DOM first, then in the light DOM
after (instead of the other way around). Lastly to support changing
either selector I allowed the 3rd parameter to be an object that could
define them (no current uses of `queryShadowFixture` pass a 3rd
parameter, but I left the option to just pass the target selector as a
string).

---------

Co-authored-by: Chris Hutchins <[email protected]>
Co-authored-by: Wilco Fiers <[email protected]>
straker added a commit that referenced this pull request Jun 29, 2026
Use `Node` instead of `HTMLElement` when checking the element internals
prop value so we include all node types, such as SVGs. This is the
follow up to a [similar problem in the `get-aria-value`
pr](#5109 (comment)).

I also added an eslint rule to prevent us from using `HTMLElements` in
the future so we don't make the same mistake again.
WilcoFiers added a commit that referenced this pull request Aug 5, 2026
All notable changes to this project will be documented in this file. See
[commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version)
for commit guidelines.

##
[4.13.0](v4.12.1...v4.13.0)
(2026-08-05)

### Features

- **aria-actions:** add aria-actions to allowed ARIA attributes
([#5200](#5200))
([029655d](029655d)),
closes [#4584](#4584)
[#5199](#5199), references
[#5215](#5215)
[#5215](#5215)
- **aria-allowed-attr:** flag deprecated ARIA attributes as needs-review
([#5246](#5246))
([518f3cc](518f3cc)),
closes [#3341](#3341)
- **aria-prohibited-attr:** allow many elements to be named and disallow
label and body from being named
([#5259](#5259))
([d8b1ea5](d8b1ea5))
- **aria-roles:** add sectionheader and sectionfooter roles
([#5238](#5238))
([c36c109](c36c109)),
closes [#4734](#4734),
references [#4734](#4734)
- **aria/get-aria-value:** new function to get aria values of a node
([#5109](#5109))
([a7d8f3e](a7d8f3e)),
references [#5042](#5042)
- **aria/has-attr-value:** new function to check if node has aria value
([#5136](#5136))
([61f2624](61f2624)),
references [#5109](#5109)
- **aria:** support role=image as equivalent to role=img
([#5248](#5248))
([5aa8aaf](5aa8aaf)),
closes [#4656](#4656),
references [#5272](#5272)
- **checks/aria:** support ARIA element internals properties
([#5172](#5172))
([9b7f754](9b7f754))
- **checks/label:** support ARIA element internals properties
([#5170](#5170))
([21c5f8b](21c5f8b))
- **checks/navigation:** support ARIA element internals properties
([#5167](#5167))
([2c3a98f](2c3a98f))
- **commons/aria:** support ARIA element internals properties
([#5171](#5171))
([31f09e7](31f09e7))
- **commons/dom:** support ARIA element internals properties
([#5163](#5163))
([f0a12cf](f0a12cf))
- **commons/forms:** support ARIA element internals properties
([#5165](#5165))
([27a4686](27a4686))
- **commons/matches/fromPrimative:** deprecate in favor of correct
spelling ([#5270](#5270))
([31cfb2e](31cfb2e))
- **commons/text:** support ARIA element internals properties
([#5169](#5169))
([e841a33](e841a33))
- **commons/text:** support form-associated labels via element internals
([#5182](#5182))
([57cfe0a](57cfe0a)),
closes [#5045](#5045),
references [#5170](#5170)
[#5039](#5039)
[#5151](#5151)
[#5039](#5039)
- **dom/getResolvedRefs:** new function to get the resolved virtual
nodes of idrefs
([#5151](#5151))
([489cdea](489cdea)),
references [#5109](#5109)
- **element-internals:** enable ElementInternals by default
([#5284](#5284))
([2740d42](2740d42)),
closes [#5277](#5277)
- **i18n:** Add Swedish locale
([#5190](#5190))
([dcd13f2](dcd13f2)),
references [#5189](#5189)
- **matches:** add inSectioningContent, hasChild, and
isSummaryForDetails matches
([#5262](#5262))
([c47cdcd](c47cdcd))
- **rules:** support ARIA element internals properties
([#5168](#5168))
([065baf7](065baf7))
- **standards/ariaAttrs:** add caseInsensitive property for attributes
([#5224](#5224))
([bcd791c](bcd791c))

### Bug Fixes

- **aria-allowed-role:** allow roles on a non-details summary
([#5242](#5242))
([3bd9875](3bd9875)),
closes [#3911](#3911),
references [#3443](#3443)
[#3911](#3911)
- **aria-allowed-role:** restrict figure roles with child figcaption
([#5240](#5240))
([178a635](178a635)),
closes [#3443](#3443)
- **aria-prohibited-attr:** visible aria-labelledby requires review only
([#5285](#5285))
([fd6fa9f](fd6fa9f))
- **axe.d.ts:** make enabled property of RuleMetadata optional
([#5129](#5129))
([90fce18](90fce18))
- **color-contrast:** fix various stacking context bugs
([#5214](#5214))
([d5e5b04](d5e5b04)),
references [#8](#8)
[#5213](#5213)
- **gather-internals:** handle non-HTMLElement nodes
([#5161](#5161))
([06e84c3](06e84c3))
- **get-selector:** escape control characters in attribute selectors
([#5273](#5273))
([4b60ac5](4b60ac5)),
closes [#5204](#5204)
[#5204](#5204)
- **image-alt:** allow whitespace alt on presentational images
([#5218](#5218))
([c5dd0ef](c5dd0ef)),
closes [#5216](#5216)
- **landmark-unique:** exclude section/form with non-landmark roles from
landmark match
([#5085](#5085))
([c5fd013](c5fd013)),
closes [#4722](#4722)
[#5064](#5064)
- name the image role in role-img-alt and svg-img-alt metadata
([#5279](#5279))
([995a269](995a269)),
closes [#5272](#5272),
references [#5248](#5248)
[#5248](#5248)
- **standards:** update aria-errormessage and aria-details to be idrefs
([#5157](#5157))
([fb94f8a](fb94f8a))

This PR was opened by a robot 🤖 🎉
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ElementInternals: create getAriaValue function

3 participants