Skip to content

Commit c0fcecd

Browse files
committed
fix(template-heading-level): exclude abstract roles from VALID_ROLE_TOKENS
1 parent d6d06f9 commit c0fcecd

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

lib/rules/template-heading-level.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,12 @@ const HEADING_RE = /^h([1-6])$/;
1313

1414
// Valid ARIA role tokens — used to find the first recognised token in a
1515
// space-separated role-fallback list (WAI-ARIA §4.1). `presentation`/`none`
16-
// are included in aria-query's role map.
17-
const VALID_ROLE_TOKENS = new Set(ariaRoles.keys());
16+
// are included in aria-query's role map. Abstract roles (e.g. `widget`,
17+
// `structure`, `landmark`) are excluded: WAI-ARIA forbids authors from using
18+
// abstract roles as `role` attribute values.
19+
const VALID_ROLE_TOKENS = new Set(
20+
[...ariaRoles.keys()].filter((name) => !ariaRoles.get(name).abstract)
21+
);
1822

1923
function extractLevel(tag) {
2024
const match = HEADING_RE.exec(tag);

0 commit comments

Comments
 (0)