8000 Merge branch 'bugfix/dialog-aria-label' into 'master' · html-validate/html-validate@12d99f0 · GitHub
[go: up one dir, main page]

Skip to content

Commit 12d99f0

Browse files
committed
Merge branch 'bugfix/dialog-aria-label' into 'master'
fix(rules): allow aria-label on `<dialog>` Closes #304 See merge request html-validate/html-validate!1146
2 parents 5b4cf1b + bd07810 commit 12d99f0

File tree

6 files changed

+39
-35
lines changed

6 files changed

+39
-35
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/elements/conformance/html-aria.js

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ async function update() {
194194
naming: "prohibited",
195195
},
196196
],
197-
"img with an accessible name.": [
197+
img: [
198198
{
199199
description: "img[alt]",
200200
selector: "img",
@@ -224,7 +224,7 @@ async function update() {
224224
naming: "allowed",
225225
},
226226
],
227-
"img with no accessible name.": [
227+
"img with no accessible name": [
228228
{
229229
description: `img[alt=""]`,
230230
selector: "img",
@@ -744,7 +744,6 @@ async function update() {
744744
.replace(/(\s+)}/gm, ",$1}") /* add trailing comma to objects */
745745
.replace(/(\s+)]/gm, ",$1]"); /* add trailing comma to arrays */
746746
const content = [
747-
`/* eslint-disable sonarjs/no-duplicate-string -- generated code */`,
748747
update.toString(),
749748
`if (require.main === module) {\n\tupdate();\n}`,
750749
`/* CONTENT BELOW IS GENERATED BY SCRIPT, CHANGES WILL BE OVERWRITTEN! */\n/* Updated: ${new Date().toUTCString()} */`,
@@ -759,7 +758,7 @@ if (require.main === module) {
759758
}
760759

761760
/* CONTENT BELOW IS GENERATED BY SCRIPT, CHANGES WILL BE OVERWRITTEN! */
762-
/* Updated: Sun, 25 Feb 2024 22:11:54 GMT */
761+
/* Updated: Sat, 28 Jun 2025 15:00:12 GMT */
763762

764763
// prettier-ignore
765764
const data = [
@@ -807,7 +806,7 @@ const data = [
807806
hash: [
808807
"884d9804999fc47a3c2694e49ad2536a",
809808
"8aa62f8eef852300db3ebf2b7a577a61",
810-
"3f679ee9b8783db0f127fb611b5254d6",
809+
"4b7a57e54b5c6233e25e820f31487ba8",
811810
],
812811
description: "address",
813812
selector: "address",
@@ -833,7 +832,7 @@ const data = [
833832
hash: [
834833
"4b82677b6c1408df4be21ada9a584fde",
835834
"5a20054581be7655f0d9b083f13eb177",
836-
"fc74b6a804f7810efbbc07e2ed78684a",
835+
"0b8f0cf0a3f366dc76efc970dfb7a90b",
837836
],
838837
description: "area",
839838
selector: "area",
@@ -1210,7 +1209,7 @@ const data = [
12101209
hash: [
12111210
"269605d45c104f12cbcdc8fb71434acc",
12121211
"3429cdcf81145c39ba806c356e4b8755",
1213-
"bb12c3ee8548dcda5c6108a56b7baa69",
1212+
"b51355ecafe6de9be9c6cbf9474f002f",
12141213
],
12151214
description: "embed",
12161215
selector: "embed",
@@ -1249,7 +1248,7 @@ const data = [
12491248
hash: [
12501249
"cb071d80d1a54f21c8867a038f6a6c66",
12511250
"8ff02f553b4103c4f5c63002947e09a4",
1252-
"8ec2fe42a078185bf12ad27f2ffb58af",
1251+
"5b848ebcfb521e774983bbc9769ba31a",
12531252
],
12541253
description: "figure",
12551254
selector: "figure",
@@ -1652,7 +1651,7 @@ const data = [
16521651
hash: [
16531652
"dc893e305df7975f7975d687c167e368",
16541653
"8aa62f8eef852300db3ebf2b7a577a61",
1655-
"3f679ee9b8783db0f127fb611b5254d6",
1654+
"4b7a57e54b5c6233e25e820f31487ba8",
16561655
],
16571656
description: "hgroup",
16581657
selector: "hgroup",
@@ -1704,7 +1703,7 @@ const data = [
17041703
hash: [
17051704
"a598e4f2afad9df861fdc476f67ef252",
17061705
"3429cdcf81145c39ba806c356e4b8755",
1707-
"bb12c3ee8548dcda5c6108a56b7baa69",
1706+
"b51355ecafe6de9be9c6cbf9474f002f",
17081707
],
17091708
description: "iframe",
17101709
selector: "iframe",
@@ -1716,8 +1715,8 @@ const data = [
17161715
id: "el-img",
17171716
hash: [
17181717
"2c15f1a6d98a9bb1dcbfc9a8e0dbff77",
1719-
"c1bd28bcf8b3a0a03198d61abede38c7",
1720-
"1eb48cd57ced991ae572f6726cde0020",
1718+
"ea75c1bc85499293cfcc0fb083fd902b",
1719+
"3a523cad6a96379f7725312df8f90f20",
17211720
],
17221721
description: "img[alt]",
17231722
selector: "img",
@@ -1729,8 +1728,8 @@ const data = [
17291728
id: "el-img",
17301729
hash: [
17311730
"7ac16255e2db6cc1a3dad4db085676f1",
1732-
"c1bd28bcf8b3a0a03198d61abede38c7",
1733-
"1eb48cd57ced991ae572f6726cde0020",
1731+
"ea75c1bc85499293cfcc0fb083fd902b",
1732+
"3a523cad6a96379f7725312df8f90f20",
17341733
],
17351734
description: "img[aria-label]",
17361735
selector: "img",
@@ -1742,8 +1741,8 @@ const data = [
17421741
id: "el-img",
17431742
hash: [
17441743
"75547b1b178a6b85e339bae02a88b72b",
1745-
"c1bd28bcf8b3a0a03198d61abede38c7",
1746-
"1eb48cd57ced991ae572f6726cde0020",
1744+
"ea75c1bc85499293cfcc0fb083fd902b",
1745+
"3a523cad6a96379f7725312df8f90f20",
17471746
],
17481747
description: "img[aria-labelledby]",
17491748
selector: "img",
@@ -1755,8 +1754,8 @@ const data = [
17551754
id: "el-img",
17561755
hash: [
17571756
"ee11b60fd17f1dd2355c94b00cecf5c9",
1758-
"c1bd28bcf8b3a0a03198d61abede38c7",
1759-
"1eb48cd57ced991ae572f6726cde0020",
1757+
"ea75c1bc85499293cfcc0fb083fd902b",
1758+
"3a523cad6a96379f7725312df8f90f20",
17601759
],
17611760
description: "img[title]",
17621761
selector: "img",
@@ -1768,8 +1767,8 @@ const data = [
17681767
id: "el-img-no-name",
17691768
hash: [
17701769
"dadb15a52164d97c794e66f8d2f90e29",
1771-
"c028f554c33f681b67373987e957f5a7",
1772-
"b44f2856f3a8ce7de57cfb4bc2ced9ce",
1770+
"c1303ef6d967483894f53b5f4a585b04",
1771+
"6fbc2de79f3ba9e9f9348a03721c6006",
17731772
],
17741773
description: "img[alt=\"\"]",
17751774
selector: "img",
@@ -1781,8 +1780,8 @@ const data = [
17811780
id: "el-img-no-name",
17821781
hash: [
17831782
"b798abe6e1b1318ee36b0dcb3fb9e4d3",
1784-
"c028f554c33f681b67373987e957f5a7",
1785-
"b44f2856f3a8ce7de57cfb4bc2ced9ce",
1783+
"c1303ef6d967483894f53b5f4a585b04",
1784+
"6fbc2de79f3ba9e9f9348a03721c6006",
17861785
],
17871786
description: "img",
17881787
selector: "img",
@@ -2250,7 +2249,7 @@ const data = [
22502249
hash: [
22512250
"d85a33464183223bd13020e94029e08d",
22522251
"63f23f292c43eac913809e9cd6f33f13",
2253-
"3f413729471cc2ce99c17d0e610f63f1",
2252+
"707461f839cfe80b1daf091869db17cd",
22542253
],
22552254
description: "ul li",
22562255
selector: "li",
@@ -2263,7 +2262,7 @@ const data = [
22632262
hash: [
22642263
"62136cc0b1265716803bac26c0fb4e16",
22652264
"63f23f292c43eac913809e9cd6f33f13",
2266-
"3f413729471cc2ce99c17d0e610f63f1",
2265+
"707461f839cfe80b1daf091869db17cd",
22672266
],
22682267
description: "ol li",
22692268
selector: "li",
@@ -2276,7 +2275,7 @@ const data = [
22762275
hash: [
22772276
"6454a8caec2b4df5c25435930075c09c",
22782277
"63f23f292c43eac913809e9cd6f33f13",
2279-
"3f413729471cc2ce99c17d0e610f63f1",
2278+
"707461f839cfe80b1daf091869db17cd",
22802279
],
22812280
description: "menu li",
22822281
selector: "li",
@@ -2289,7 +2288,7 @@ const data = [
22892288
hash: [
22902289
"d70c1e5d44de8a9150eb91ecff563578",
22912290
"63f23f292c43eac913809e9cd6f33f13",
2292-
"3f413729471cc2ce99c17d0e610f63f1",
2291+
"707461f839cfe80b1daf091869db17cd",
22932292
],
22942293
description: "li",
22952294
selector: "li",
@@ -2393,7 +2392,7 @@ const data = [
23932392
hash: [
23942393
"558ddfdd3620c111fe112b4671b77c6d",
23952394
"9d83791c856392352dba886d559d527c",
2396-
"1d8974390604e72f35cda3e1189a9411",
2395+
"2a5e325888e5b2782be2c5eea9c31955",
23972396
],
23982397
description: "meter",
23992398
selector: "meter",
@@ -2432,7 +2431,7 @@ const data = [
24322431
hash: [
24332432
"a8cfde6331bd59eb2ac96f8911c4b666",
24342433
"3429cdcf81145c39ba806c356e4b8755",
2435-
"e06961f51405680d6289f878788790bd",
2434+
"b47cec882853faae0ca6ce9a1def4500",
24362435
],
24372436
description: "object",
24382437
selector: "object",

src/elements/conformance/wai-aria.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ if (require.main === module) {
3737
}
3838

3939
/* CONTENT BELOW IS GENERATED BY SCRIPT, CHANGES WILL BE OVERWRITTEN! */
40-
/* Updated: Sun Feb 18 2024 14:25:33 GMT+0100 (GMT+01:00) */
40+
/* Updated: Sat Jun 28 2025 15:05:23 GMT+0200 (GMT+02:00) */
4141

4242
const data = [
4343
{

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)
0