Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions lib/rules/template-no-nested-landmark.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ const LANDMARK_ROLES = new Set([
'form',
'main',
'navigation',
'region',
'search',
]);

const LANDMARK_ELEMENTS = new Set(['header', 'aside', 'footer', 'form', 'main', 'nav', 'section']);
const LANDMARK_ELEMENTS = new Set(['header', 'aside', 'footer', 'form', 'main', 'nav']);

const EQUIVALENT_ROLE = {
aside: 'complementary',
Expand Down
9 changes: 9 additions & 0 deletions tests/lib/rules/template-no-nested-landmark.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@ ruleTester.run('template-no-nested-landmark', rule, {
'<template><div role="banner"><nav></nav></div></template>',
'<template><header><div role="navigation"></div></header></template>',
'<template><div role="banner"><div role="navigation"></div></div></template>',

// `<section>` only gets the `region` landmark role when it has an accessible name
// (aria-label/aria-labelledby/title). Without one it has the generic role — see
// https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/section.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Image

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MDN is inconsistent on this — checked the HTML-AAM spec directly: https://www.w3.org/TR/html-aam-1.0/#el-section — "region role if the section element has an accessible name. Otherwise, the generic role."

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tyty

// This rule does not inspect accessible names, so unnamed sections are excluded.
'<template><section><section>Content</section></section></template>',
// `role="region"` is the landmark role a named `<section>` gets. Nesting it is
// excluded for the same reason: the rule cannot verify an accessible name is present.
'<template><div role="region"><div role="region">Content</div></div></template>',
],

invalid: [
Expand Down
Loading