Skip to content

Commit

Permalink
fix: add normalizer for matching aria-label (#855)
Browse files Browse the repository at this point in the history
  • Loading branch information
johnjesse authored Jan 7, 2021
1 parent ec1b642 commit 5831f60
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/__tests__/text-matchers.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,10 @@ cases(
<input id="username" />`,
queryFn: 'queryAllByLabelText',
},
queryAllByAriaLabelText: {
dom: `<div aria-label="User ${LRM}name"/>`,
queryFn: 'queryAllByLabelText',
},
queryAllByPlaceholderText: {
dom: `<input placeholder="User ${LRM}name" />`,
queryFn: 'queryAllByPlaceholderText',
Expand Down
7 changes: 6 additions & 1 deletion src/queries/label-text.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,12 @@ function queryAllByLabelText(

return labelledElements
}, [])
.concat(queryAllByAttribute('aria-label', container, text, {exact}))
.concat(
queryAllByAttribute('aria-label', container, text, {
exact,
normalizer: matchNormalizer,
}),
)

return Array.from(new Set(matchingLabelledElements)).filter(element =>
element.matches(selector),
Expand Down

0 comments on commit 5831f60

Please sign in to comment.