Skip to content

Commit 1239182

Browse files
IanVSeps1lon
andauthored
feat: Use ARIA 1.2 for role queries (#1058)
Co-authored-by: eps1lon <silbermann.sebastian@gmail.com>
1 parent b569a1b commit 1239182

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"@babel/code-frame": "^7.10.4",
4343
"@babel/runtime": "^7.12.5",
4444
"@types/aria-query": "^4.2.0",
45-
"aria-query": "^4.2.2",
45+
"aria-query": "^5.0.0",
4646
"chalk": "^4.1.0",
4747
"dom-accessibility-api": "^0.5.6",
4848
"lz-string": "^1.4.4",

src/__tests__/__snapshots__/role-helpers.js.snap

+16
Original file line numberDiff line numberDiff line change
@@ -200,5 +200,21 @@ Name "":
200200
data-testid="a-textarea"
201201
/>
202202
203+
--------------------------------------------------
204+
term:
205+
206+
Name "":
207+
<dt
208+
data-testid="a-dt"
209+
/>
210+
211+
--------------------------------------------------
212+
definition:
213+
214+
Name "":
215+
<dd
216+
data-testid="a-dd"
217+
/>
218+
203219
--------------------------------------------------
204220
`;

src/__tests__/role-helpers.js

+16
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ afterEach(() => {
1616

1717
function setup() {
1818
const {getByTestId} = render(`
19+
<header data-testid="a-header">Banner header</header>
1920
<section aria-label="a region" data-testid='named-section'>
2021
<a href="http://whatever.com" data-testid="a-link">link</a>
2122
<a>invalid link</a>
@@ -66,6 +67,10 @@ function setup() {
6667
<form data-testid="a-form" />
6768
<section data-testid="a-section" />
6869
</article>
70+
<dl>
71+
<dt data-testid="a-dt">Term</dt>
72+
<dd data-testid="a-dd">Definition</dd>
73+
</dl>
6974
</section>
7075
`)
7176

@@ -99,6 +104,9 @@ function setup() {
99104
input: getByTestId('a-input-1'),
100105
input2: getByTestId('a-input-2'),
101106
textarea: getByTestId('a-textarea'),
107+
dt: getByTestId('a-dt'),
108+
dd: getByTestId('a-dd'),
109+
header: getByTestId('a-header'),
102110
}
103111
}
104112

@@ -131,6 +139,9 @@ test('getRoles returns expected roles for various dom nodes', () => {
131139
textarea,
132140
namedSection,
133141
namedForm,
142+
dd,
143+
dt,
144+
header,
134145
} = setup()
135146

136147
expect(getRoles(namedSection)).toEqual({
@@ -150,6 +161,11 @@ test('getRoles returns expected roles for various dom nodes', () => {
150161
menuitem: [menuItem, menuItem2],
151162
form: [namedForm],
152163
region: [namedSection],
164+
term: [dt],
165+
definition: [dd],
166+
})
167+
expect(getRoles(header)).toEqual({
168+
banner: [header],
153169
})
154170
})
155171

0 commit comments

Comments
 (0)