jest-dom icon indicating copy to clipboard operation
jest-dom copied to clipboard

fix: updates support for aria-required attribute in `to-be-required`

Open JatinRanka opened this issue 11 months ago • 0 comments

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 of true, to indicate to assistive technologies that user input is required on the element for the form to be submittable. The aria-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

JatinRanka avatar Mar 12 '24 17:03 JatinRanka