-
Notifications
You must be signed in to change notification settings - Fork 470
Add semantic HTML elements implicit role support to queryByRole/getByRole selectors #262
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
Comments
Ah, that's tricky. I'd be open to expanding I don't currently have the bandwidth to do it myself, but here's the source file: https://github.com/testing-library/dom-testing-library/blob/master/src/queries/role.js and I'd probably recommend making a test file for this specifically in: https://github.com/testing-library/dom-testing-library/tree/master/src/__tests__ |
https://www.npmjs.com/package/aria-query npm package could help us to start expanding role and I can see it within node_modules in the dom-testing-library (however it's not listed in package.json as a dependency). What do you think about its usage? Another approach to implementing it ourselves based on W3C specification. |
That package sounds perfect 👍 |
I've started to implement it. |
…/getByRole selectors (testing-library#262) * Add aria-query library as a dependency * Extend queryByRole to use aria-query ARIA roles to identify semantic HTML elements
…/getByRole selectors (testing-library#262) * Add aria-query library as a dependency * Extend queryByRole to use aria-query ARIA roles to identify semantic HTML elements
Describe the feature you'd like:
queryByRole/getByRole
selectors can return only those HTML elements which specified role explicitly (attributerole
is defined explicitly). However semantic HTML elements (table column headers, table cells, textbox, etc.) have implicit ARIA roles and selectors should support those either. Example: https://codesandbox.io/s/domtestinglibraryariaroles-q5vkk?fontsize=14&module=%2Fsrc%2Findex.spec.tsxSuggested implementation:
The following unit test shouldn't fail:
Describe alternatives you've considered:
The only alternative is to provide ARIA roles explicitly, but it increases redundancy and it's not so elegant either.
Teachability, Documentation, Adoption, Migration Strategy:
The text was updated successfully, but these errors were encountered: