Skip to content

Commit e81aeb2

Browse files
Merge pull request #2719 from johanrd/fix/aria-unsupported-extend-to-dom-reserved
BUGFIX: template-no-aria-unsupported-elements — source the reserved-element list from aria-query
2 parents df5c01c + 785f58c commit e81aeb2

2 files changed

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

0 commit comments

Comments
 (0)