-
Notifications
You must be signed in to change notification settings - Fork 850
fix(core): stop ignoring shadow roots in context #4952
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the pr, it's a great start. For handling shadow roots, instead of adding the host element we should instead add all the children of the shadow root. This way if there are accessibility violations on the host node we do not report them since the shadow root was passed in and not the host node itself.
We'll also want a test added to https://github.com/dequelabs/axe-core/blob/develop/test/core/base/context.js under the describe('include') block that tests that passing a shadow root to the context will add all it's children. You can use createNestedShadowDom (and tests that use it) to make creating the shadow DOM element and children easier.
|
|
| it('should not mutate exclude in input', () => { | ||
| fixture.innerHTML = '<div id="foo"></div>'; | ||
| const context = { exclude: [['iframe', '#foo']] }; | ||
| // eslint-disable-next-line no-new |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed by a pre-commit hook.
|
@straker thanks for the review! I followed your guidance, updated the logic and wrote a test. Could you please take another look? |
By the way, I did previously sign the CLA, not sure why the bot is complaining: #4859 |
|
Fixed format. |
Before: if a shadow root (not the shadow host element, but an actual
ShadowRootinstance) is passed as part of context, it's silently ignored.After: the shadow root node is substituted with its host element for the rest of Axe algorithms to work with.
Closes: #4941