jest-dom
jest-dom copied to clipboard
fix: updates support for aria-required attribute in `to-be-required`
What:
The non-semantic HTML element fails toBeRequired
method even though aria-required is set as true
- #481
It does not implement this part of what's documented in MDN:
When form controls are created using non-semantic elements, such as a <div> with a role of checkbox, the
aria-required
attribute should be included, with a value oftrue
, to indicate to assistive technologies that user input is required on the element for the form to be submittable. Thearia-required
attribute can be used with HTML form elements; it is not limited to elements that have an ARIA role assigned.
Why:
The current code only only adheres to aria-required
attribute for a set of HTML elements
How:
Updated the toBeRequired
method to not depend on tag type or role type for elements with aria-required
attribute
Checklist:
- [x] Documentation
- [x] Tests
- [x] Updated Type Definitions
- [x] Ready to be merged