Skip to content

test(arialabelledby-text): cover closed shadow DOM and out-of-tree idrefs - #5287

Merged
WilcoFiers merged 5 commits into
developfrom
chut/5221-closed-shadow-idref-tests
Aug 5, 2026
Merged

test(arialabelledby-text): cover closed shadow DOM and out-of-tree idrefs#5287
WilcoFiers merged 5 commits into
developfrom
chut/5221-closed-shadow-idref-tests

Conversation

@chutchins25

Copy link
Copy Markdown
Contributor

Summary

Adds tests codifying how axe-core handles idref references that point outside its virtual tree — the two scenarios in #5221:

  1. Closed shadow DOM — a custom element self-labels via ElementInternals.ariaLabelledByElements with a node inside its own closed shadow root. Closed roots aren't flattened into the virtual tree, so the reference is unreachable.
  2. Out-of-tree nodeariaLabelledByElements points at a node appended after axe.setup(), so it never enters the tree.

Both codify the current behavior: getResolvedRefs maps the unreachable node to null, the accessible-name function drops it, and arialabelledbyText returns "" without throwing.

Notes

  • Tests-only; no runtime behavior change.
  • The closed-shadow case is built with manual DOM (attachShadow({ mode: "closed" })) since queryShadowFixture is open-mode only.

Closes #5221

…refs

Codify that aria-labelledby / ariaLabelledByElements references pointing
at a node in a closed shadow root or outside the virtual tree resolve to
no accessible name without throwing.

Closes #5221
Cover the string aria-labelledby path where the referenced id lives in a
closed declarative shadow root, unresolvable from the light DOM.

Closes #5221
@chutchins25
chutchins25 marked this pull request as ready for review August 5, 2026 15:30
@chutchins25
chutchins25 requested a review from a team as a code owner August 5, 2026 15:30
Copilot AI review requested due to automatic review settings August 5, 2026 15:30

Copilot AI 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.

Pull request overview

Adds regression tests to the aria.arialabelledbyText accessible-name helper to codify how axe-core behaves when ARIA idref resolution points outside the current virtual tree (closed Shadow DOM and nodes added after axe.setup()), ensuring the result is "" and no exception is thrown (issue #5221).

Changes:

  • Add a test for ElementInternals.ariaLabelledByElements referencing a node inside a closed shadow root.
  • Add a test for aria-labelledby="id" referencing an ID inside a closed declarative shadow root.
  • Add a test for ariaLabelledByElements referencing a node appended after axe.setup() (out-of-tree).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Drop the declarative-shadow-DOM string-idref case and remove
issue-number suffixes from the test names.
@WilcoFiers
WilcoFiers merged commit 98400d7 into develop Aug 5, 2026
23 checks passed
@WilcoFiers
WilcoFiers deleted the chut/5221-closed-shadow-idref-tests branch August 5, 2026 16:03
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.

Add tests for closed shadow DOM and lookups outside the virtual tree

4 participants