Skip to content

Commit 94d8382

Browse files
committed
fix(template-no-aria-unsupported-elements): source reserved-element list from aria-query
The rule's hand-maintained set covered 8 elements: meta, html, script, style, title, base, head, link aria-query's dom map marks 16 elements as reserved (its source is HTML-AAM §2, which lists every element that must not have ARIA): base, col, colgroup, head, html, link, meta, noembed, noscript, param, picture, script, source, style, title, track Replace the hand-list with a filtered view of aria-query's dom map. aria-query is already a dependency (used elsewhere for role/attribute validation). No new dependency, no behavioural regression — the new set is a superset of the old one. Six new invalid tests cover the previously-missing elements: col, colgroup, noscript, picture, source, track.
1 parent 24882a3 commit 94d8382

2 files changed

Lines changed: 41 additions & 12 deletions

File tree

lib/rules/template-no-aria-unsupported-elements.js

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
const { dom } = require('aria-query');
2+
3+
// HTML elements that don't support ARIA — sourced from aria-query's dom map,
4+
// which marks spec-reserved elements with .reserved = true. Matches the authoritative
5+
// list in the HTML-AAM spec (https://www.w3.org/TR/html-aria/#docconformance).
6+
const ELEMENTS_WITHOUT_ARIA_SUPPORT = new Set(
7+
[...dom].filter(([, def]) => def.reserved).map(([tag]) => tag)
8+
);
9+
110
/** @type {import('eslint').Rule.RuleModule} */
211
module.exports = {
312
meta: {
@@ -24,18 +33,6 @@ module.exports = {
2433
},
2534

2635
create(context) {
27-
// Elements that don't support ARIA
28-
const ELEMENTS_WITHOUT_ARIA_SUPPORT = new Set([
29-
'meta',
30-
'html',
31-
'script',
32-
'style',
33-
'title',
34-
'base',
35-
'head',
36-
'link',
37-
]);
38-
3936
return {
4037
GlimmerElementNode(node) {
4138
if (ELEMENTS_WITHOUT_ARIA_SUPPORT.has(node.tag)) {

tests/lib/rules/template-no-aria-unsupported-elements.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,37 @@ ruleTester.run('template-no-aria-unsupported-elements', rule, {
2929
output: null,
3030
errors: [{ messageId: 'unsupported' }],
3131
},
32+
33+
// Newly covered by aria-query's dom.reserved list.
34+
{
35+
code: '<template><col role="presentation" /></template>',
36+
output: null,
37+
errors: [{ messageId: 'unsupported' }],
38+
},
39+
{
40+
code: '<template><colgroup aria-label="x" /></template>',
41+
output: null,
42+
errors: [{ messageId: 'unsupported' }],
43+
},
44+
{
45+
code: '<template><noscript aria-hidden="true" /></template>',
46+
output: null,
47+
errors: [{ messageId: 'unsupported' }],
48+
},
49+
{
50+
code: '<template><picture aria-label="x" /></template>',
51+
output: null,
52+
errors: [{ messageId: 'unsupported' }],
53+
},
54+
{
55+
code: '<template><source aria-label="x" /></template>',
56+
output: null,
57+
errors: [{ messageId: 'unsupported' }],
58+
},
59+
{
60+
code: '<template><track aria-label="x" /></template>',
61+
output: null,
62+
errors: [{ messageId: 'unsupported' }],
63+
},
3264
],
3365
});

0 commit comments

Comments
 (0)