From f07093f2ec928ce1d2e83a1d17092759ef0448f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johan=20R=C3=B8ed?= Date: Tue, 21 Apr 2026 08:48:11 +0200 Subject: [PATCH 1/3] refactor(template-require-presentational-children): source role list from aria-query MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- ...emplate-require-presentational-children.js | 26 ++++++------------- 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/lib/rules/template-require-presentational-children.js b/lib/rules/template-require-presentational-children.js index 172c18ba76..45676a9194 100644 --- a/lib/rules/template-require-presentational-children.js +++ b/lib/rules/template-require-presentational-children.js @@ -1,21 +1,11 @@ -// Roles that require all descendants to be presentational -// https://w3c.github.io/aria-practices/#children_presentational -const ROLES_REQUIRING_PRESENTATIONAL_CHILDREN = new Set([ - 'button', - 'checkbox', - 'img', - 'meter', - 'menuitemcheckbox', - 'menuitemradio', - 'option', - 'progressbar', - 'radio', - 'scrollbar', - 'separator', - 'slider', - 'switch', - 'tab', -]); +const { roles } = require('aria-query'); + +// Roles where descendants are presentational per the ARIA "Children +// Presentational" rule. Derived from aria-query (role.childrenPresentational). +// https://www.w3.org/TR/wai-aria-1.2/#childrenArePresentational +const ROLES_REQUIRING_PRESENTATIONAL_CHILDREN = new Set( + [...roles.keys()].filter((role) => roles.get(role).childrenPresentational) +); // Tags that do not have semantic meaning const NON_SEMANTIC_TAGS = new Set([ From 7a8bb2934c0f64f7fcdf511bb1105b6817b2c42c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johan=20R=C3=B8ed?= Date: Tue, 21 Apr 2026 10:52:37 +0200 Subject: [PATCH 2/3] test: add coverage for doc-pagebreak and graphics-symbol additions --- ...emplate-require-presentational-children.js | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/tests/lib/rules/template-require-presentational-children.js b/tests/lib/rules/template-require-presentational-children.js index e6504e5785..0251ddec35 100644 --- a/tests/lib/rules/template-require-presentational-children.js +++ b/tests/lib/rules/template-require-presentational-children.js @@ -35,6 +35,12 @@ ruleTester.run('template-require-presentational-children', rule, { Title here `, + // SKIPPED_TAGS: is always skipped, even when its role has childrenPresentational + // (graphics-symbol is such a role via Graphics-ARIA; this covers the new aria-query-derived set). + ``, `

pg

', + output: null, + errors: [ + { + message: + '
has a role of doc-pagebreak, it cannot have semantic descendants like

', + }, + ], + }, + // graphics-symbol: Graphics-ARIA role with childrenPresentational; flags on non-svg host. + { + code: '', + output: null, + errors: [ + { + message: + '
has a role of graphics-symbol, it cannot have semantic descendants like ', + }, + ], + }, ], }); @@ -109,6 +137,12 @@ hbsRuleTester.run('template-require-presentational-children', rule, { Title here `, + // SKIPPED_TAGS: is always skipped, even when its role has childrenPresentational + // (graphics-symbol is such a role via Graphics-ARIA; this covers the new aria-query-derived set). + ` + + + `, ` <:default>Button text @@ -150,5 +184,27 @@ hbsRuleTester.run('template-require-presentational-children', rule, { }, ], }, + // doc-pagebreak: DPUB-ARIA role with childrenPresentational; now included via aria-query. + { + code: '

pg

', + output: null, + errors: [ + { + message: + '
has a role of doc-pagebreak, it cannot have semantic descendants like

', + }, + ], + }, + // graphics-symbol: Graphics-ARIA role with childrenPresentational; flags on non-svg host. + { + code: '
X
', + output: null, + errors: [ + { + message: + '
has a role of graphics-symbol, it cannot have semantic descendants like ', + }, + ], + }, ], }); From ec16ce42b2543c3570c76757d71f7f858f634478 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johan=20R=C3=B8ed?= Date: Tue, 21 Apr 2026 16:23:32 +0200 Subject: [PATCH 3/3] chore: drop temporal 'now included via aria-query' comments --- .../template-require-presentational-children.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/lib/rules/template-require-presentational-children.js b/tests/lib/rules/template-require-presentational-children.js index 0251ddec35..1a15cf021b 100644 --- a/tests/lib/rules/template-require-presentational-children.js +++ b/tests/lib/rules/template-require-presentational-children.js @@ -35,8 +35,8 @@ ruleTester.run('template-require-presentational-children', rule, { Title here `, - // SKIPPED_TAGS: is always skipped, even when its role has childrenPresentational - // (graphics-symbol is such a role via Graphics-ARIA; this covers the new aria-query-derived set). + // SKIPPED_TAGS: is always skipped, even when its role has + // childrenPresentational (e.g. graphics-symbol via Graphics-ARIA). `

pg

', output: null, @@ -137,8 +137,8 @@ hbsRuleTester.run('template-require-presentational-children', rule, { Title here `, - // SKIPPED_TAGS: is always skipped, even when its role has childrenPresentational - // (graphics-symbol is such a role via Graphics-ARIA; this covers the new aria-query-derived set). + // SKIPPED_TAGS: is always skipped, even when its role has + // childrenPresentational (e.g. graphics-symbol via Graphics-ARIA). ` @@ -184,7 +184,7 @@ hbsRuleTester.run('template-require-presentational-children', rule, { }, ], }, - // doc-pagebreak: DPUB-ARIA role with childrenPresentational; now included via aria-query. + // doc-pagebreak: DPUB-ARIA role with childrenPresentational. { code: '

pg

', output: null,