Skip to content

Commit f07093f

Browse files
committed
refactor(template-require-presentational-children): source role list from aria-query
Replaces a hand-maintained list of 14 roles with a derivation from aria-query's role.childrenPresentational flag. Coverage grows from 14 to 16 roles — aria-query also includes doc-pagebreak (DPUB-ARIA) and graphics-symbol (Graphics-ARIA), both of which spec-require presentational children. Previously those would have been silently accepted. Spec: WAI-ARIA 1.2 — Children Presentational https://www.w3.org/TR/wai-aria-1.2/#childrenArePresentational
1 parent 24882a3 commit f07093f

1 file changed

Lines changed: 8 additions & 18 deletions

File tree

lib/rules/template-require-presentational-children.js

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,11 @@
1-
// Roles that require all descendants to be presentational
2-
// https://w3c.github.io/aria-practices/#children_presentational
3-
const ROLES_REQUIRING_PRESENTATIONAL_CHILDREN = new Set([
4-
'button',
5-
'checkbox',
6-
'img',
7-
'meter',
8-
'menuitemcheckbox',
9-
'menuitemradio',
10-
'option',
11-
'progressbar',
12-
'radio',
13-
'scrollbar',
14-
'separator',
15-
'slider',
16-
'switch',
17-
'tab',
18-
]);
1+
const { roles } = require('aria-query');
2+
3+
// Roles where descendants are presentational per the ARIA "Children
4+
// Presentational" rule. Derived from aria-query (role.childrenPresentational).
5+
// https://www.w3.org/TR/wai-aria-1.2/#childrenArePresentational
6+
const ROLES_REQUIRING_PRESENTATIONAL_CHILDREN = new Set(
7+
[...roles.keys()].filter((role) => roles.get(role).childrenPresentational)
8+
);
199

2010
// Tags that do not have semantic meaning
2111
const NON_SEMANTIC_TAGS = new Set([

0 commit comments

Comments
 (0)