Repository navigation
fix(record): resolve aria-labelledby inside the target's own tree - #774
Open
openviking-superagent wants to merge 1 commit into
Open
openviking-superagent wants to merge 1 commit into
openviking-superagent wants to merge 1 commit into
Conversation
A Shadow DOM button that labels itself with a sibling in the same shadow root lost its accessible name: labelledByText looked the id up on document, so the inner label was invisible, and when the outer page used the same id the descriptor took the unrelated outer text. Resolve IDREFs in el.getRootNode() first and fall back to the outer document only when the element's own tree has no such id. Add regression tests for both reported scenarios plus the light-DOM path.
This branch has not been deployed
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.
Fixes #646.
A Shadow DOM button labelled by a sibling in the same shadow root lost its name during recording.
labelledByText()resolved everyaria-labelledbyIDREF withdocument.getElementById, so an inner label was invisible, and when the outer page happened to use the same id the descriptor took the unrelated outer text. Chromium's AX tree reports the local label in both cases.What changed
labelledByText()now resolves each IDREF inel.getRootNode()(the element's own tree, as ARIA does) and falls back to the outer document only when that tree has no such id. This is duck-typed ongetElementByIdrather thaninstanceof Document/ShadowRoot, which also keeps it working in test environments where the global constructors differ from the document's.Verification
New cases in
src/lib/__tests__/describe-target.test.ts:name: "Save"(previously: no step at all);Delete account);vitest run src/lib/__tests__/describe-target.test.ts— 15/15.tsc --noEmitandbiome checkpass on both files.labelledByTextwas the reported path;associatedLabelText()has the samedocument-scope assumption forlabel[for]inside a shadow root and is left for a separate change so this stays reviewable.