test(arialabelledby-text): cover closed shadow DOM and out-of-tree idrefs - #5287
Merged
Conversation
…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
Contributor
There was a problem hiding this comment.
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.ariaLabelledByElementsreferencing 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
ariaLabelledByElementsreferencing a node appended afteraxe.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
approved these changes
Aug 5, 2026
straker
approved these changes
Aug 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds tests codifying how axe-core handles idref references that point outside its virtual tree — the two scenarios in #5221:
ElementInternals.ariaLabelledByElementswith a node inside its own closed shadow root. Closed roots aren't flattened into the virtual tree, so the reference is unreachable.ariaLabelledByElementspoints at a node appended afteraxe.setup(), so it never enters the tree.Both codify the current behavior:
getResolvedRefsmaps the unreachable node tonull, the accessible-name function drops it, andarialabelledbyTextreturns""without throwing.Notes
attachShadow({ mode: "closed" })) sincequeryShadowFixtureis open-mode only.Closes #5221