Skip to content

Commit 5831f60

Browse files
authored
fix: add normalizer for matching aria-label (#855)
1 parent ec1b642 commit 5831f60

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/__tests__/text-matchers.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,10 @@ cases(
231231
<input id="username" />`,
232232
queryFn: 'queryAllByLabelText',
233233
},
234+
queryAllByAriaLabelText: {
235+
dom: `<div aria-label="User ${LRM}name"/>`,
236+
queryFn: 'queryAllByLabelText',
237+
},
234238
queryAllByPlaceholderText: {
235239
dom: `<input placeholder="User ${LRM}name" />`,
236240
queryFn: 'queryAllByPlaceholderText',

src/queries/label-text.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,12 @@ function queryAllByLabelText(
9191

9292
return labelledElements
9393
}, [])
94-
.concat(queryAllByAttribute('aria-label', container, text, {exact}))
94+
.concat(
95+
queryAllByAttribute('aria-label', container, text, {
96+
exact,
97+
normalizer: matchNormalizer,
98+
}),
99+
)
95100

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

0 commit comments

Comments
 (0)