Skip to content

Commit bd07810

Browse files
committed
fix(rules): allow aria-label on <dialog>
fixes #304
1 parent cfcf1bb commit bd07810

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed

docs/rules/aria-label-misuse.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ The attribute can only be used on the following elements:
1919
- Landmark elements
2020
- Elements with roles inheriting from widget
2121
- `<area>`
22+
- `<dialog>`
2223
- `<form>` and `<fieldset>`
2324
- `<iframe>`
2425
- `<img>` and `<figure>`

src/rules/__snapshots__/aria-label-misuse.spec.ts.snap

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Jest Snapshot v1, https://goo.gl/fbAQLP
1+
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
22

33
exports[`rule aria-label-misuse should contain documentation 1`] = `
44
{
@@ -9,6 +9,7 @@ exports[`rule aria-label-misuse should contain documentation 1`] = `
99
- Landmark elements
1010
- Elements with roles inheriting from widget
1111
- \`<area>\`
12+
- \`<dialog>\`
1213
- \`<form>\` and \`<fieldset>\`
1314
- \`<iframe>\`
1415
- \`<img>\` and \`<figure>\`

src/rules/aria-label-misuse.spec.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ describe("rule aria-label-misuse", () => {
6868
${'<p role="widget" aria-label="foobar">'} | ${'[role=".."]'}
6969
${'<p tabindex="0" aria-label="foobar"></p>'} | ${"[tabindex]"}
7070
${'<area aria-label="foobar"></area>'} | ${"<area>"}
71+
${'<dialog aria-label="foobar"></dialog>'} | ${"<dialog>"}
7172
${'<form aria-label="foobar"></form>'} | ${"<form>"}
7273
${'<fieldset aria-label="foobar"></fieldset>'} | ${"<fieldset>"}
7374
${'<iframe aria-label="foobar"></iframe>'} | ${"<iframe>"}
@@ -198,11 +199,11 @@ describe("rule aria-label-misuse", () => {
198199
const report = await htmlvalidate.validateString(markup);
199200
expect(report).toBeInvalid();
200201
expect(report).toMatchInlineCodeframe(`
201-
"error: "aria-label" cannot be used on this element (aria-label-misuse) at inline:1:6:
202-
> 1 | <h1 aria-label="lorem ipsum">spam</h1>
203-
| ^^^^^^^^^^
204-
Selector: h1"
205-
`);
202+
"error: "aria-label" cannot be used on this element (aria-label-misuse) at inline:1:6:
203+
> 1 | <h1 aria-label="lorem ipsum">spam</h1>
204+
| ^^^^^^^^^^
205+
Selector: h1"
206+
`);
206207
});
207208
});
208209

src/rules/aria-label-misuse.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ const whitelisted = [
2323
"footer",
2424
"section",
2525
"article",
26+
"dialog",
2627
"form",
2728
"img",
2829
"area",
@@ -73,6 +74,7 @@ export default class AriaLabelMisuse extends Rule<void, RuleOptions> {
7374
"Landmark elements",
7475
"Elements with roles inheriting from widget",
7576
"`<area>`",
77+
"`<dialog>`",
7678
"`<form>` and `<fieldset>`",
7779
"`<iframe>`",
7880
"`<img>` and `<figure>`",

0 commit comments

Comments
 (0)