Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: null labels on hidden inputs (#804)
* Ensure hidden inputs are not labelable The `labels` property on `input` elements of type `hidden` is `null` rather than `NodeList` [1]. This meant the `getRealLabels` function would return `null` causing `queryAllByLabelText` to throw an error when it tried to call `length` on `null` [2]. This commit fixes the issue by ensuring the element is labelable before calling `labels` on it, and adds a test case for this specific scenario. [1]: https://html.spec.whatwg.org/multipage/forms.html#dom-lfe-labels [2]: https://github.com/testing-library/dom-testing-library/blob/62f4e5e09a4b81ef66679560b540523edccdef98/src/queries/label-text.js#L52 * squash! Ensure hidden inputs are not labelable This commit fixes the issue by retuning an empty array if the `labels` property is `null`, and adds a test case for this specific scenario.
- Loading branch information