Skip to content

Commit 623705b

Browse files
Merge pull request #2694 from johanrd/day_fix/template-no-nested-landmark
Post-merge-review: Fix template-no-nested-landmark: drop port-only section/region
2 parents dcd8c51 + d553f24 commit 623705b

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

lib/rules/template-no-nested-landmark.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,10 @@ const LANDMARK_ROLES = new Set([
55
'form',
66
'main',
77
'navigation',
8-
'region',
98
'search',
109
]);
1110

12-
const LANDMARK_ELEMENTS = new Set(['header', 'aside', 'footer', 'form', 'main', 'nav', 'section']);
11+
const LANDMARK_ELEMENTS = new Set(['header', 'aside', 'footer', 'form', 'main', 'nav']);
1312

1413
const EQUIVALENT_ROLE = {
1514
aside: 'complementary',

tests/lib/rules/template-no-nested-landmark.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,15 @@ ruleTester.run('template-no-nested-landmark', rule, {
4242
'<template><div role="banner"><nav></nav></div></template>',
4343
'<template><header><div role="navigation"></div></header></template>',
4444
'<template><div role="banner"><div role="navigation"></div></div></template>',
45+
46+
// `<section>` only gets the `region` landmark role when it has an accessible name
47+
// (aria-label/aria-labelledby/title). Without one it has the generic role — see
48+
// https://www.w3.org/TR/html-aam-1.0/#el-section
49+
// This rule does not inspect accessible names, so unnamed sections are excluded.
50+
'<template><section><section>Content</section></section></template>',
51+
// `role="region"` is the landmark role a named `<section>` gets. Nesting it is
52+
// excluded for the same reason: the rule cannot verify an accessible name is present.
53+
'<template><div role="region"><div role="region">Content</div></div></template>',
4554
],
4655

4756
invalid: [

0 commit comments

Comments
 (0)