Repository navigation
fix(tree): traverse open shadow roots and resolved slots in accessibility tree - #239
Open
AdamMagued wants to merge 1 commit into
Open
AdamMagued wants to merge 1 commit into
AdamMagued wants to merge 1 commit into
Conversation
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.
Description
Resolves #182
This PR adds support for traversing open Shadow DOM roots and resolving elements when building the accessibility tree.
Summary of Changes
Open Shadow DOM Traversal:
src/createAccessibilityTree.ts, when a node has an open shadow root (isElement(node) && node.shadowRoot), its child nodes are traversed vianode.shadowRoot.childNodesinstead of light DOMchildNodes.<slot>are excluded from the accessibility tree per the HTML Accessibility API Mappings.Slot Resolution and Tree Flattening:
<slot>elements, assigned nodes are resolved usingslot.assignedNodes({ flatten: true }).Shadow-Aware Node Lookup and Relationship Attributes:
src/getNodeByIdRef.ts, ID references are looked up across open shadow roots recursively when not found in the root container scope.src/createAccessibilityTree.ts, deep shadow queries are used for[aria-flowto]and[aria-owns]attributes to properly construct alternate reading orders and owned element relationships across shadow DOM boundaries.DOM Observation and Focus Handling:
src/observeDOM.ts, mutation observers are attached to open shadow roots and dynamically added shadow subtrees so that tree invalidation and live regions work inside web components.src/Virtual.ts,#handleFocusChangesynchronously retrievesevent.composedPath()[0]before yielding to ticks, ensuring focus transitions to elements inside shadow DOM correctly update the active node.src/getElementFromNode.tsandsrc/getLiveSpokenPhrase.ts, shadow boundary crossings viatarget.parentNode.hostare handled when resolving target elements and live region ancestors.Tests:
test/createAccessibilityTreeShadowDom.test.tscovering open shadow root traversal, slot unwrapping, fallback content, and shadow-awaregetNodeByIdRef.test/int/shadowDom.int.test.tscovering full screen reader navigation, named slots, fallback content, landmark commands, link commands, heading commands, clicking/focusing inside shadow DOM, and live region mutations inside shadow roots.