|
2 | 2 |
|
3 | 3 | <!-- end auto-generated rule header --> |
4 | 4 |
|
5 | | -Disallows duplicate landmark elements without unique labels. |
6 | | - |
7 | | -HTML5 landmark elements (like `<nav>`, `<header>`, `<footer>`, etc.) help screen reader users navigate a page. When multiple landmarks of the same type exist, each must have a unique label to distinguish them. |
| 5 | +If multiple landmark elements of the same type are found on a page, they must each have a unique label (provided by `aria-label` or `aria-labelledby`). |
8 | 6 |
|
9 | 7 | ## Rule Details |
10 | 8 |
|
11 | | -This rule ensures that when multiple landmark elements of the same type appear in a template, each has a unique `aria-label` or `aria-labelledby` attribute. |
12 | | - |
13 | | -Landmark elements checked: |
| 9 | +List of elements & their corresponding roles: |
14 | 10 |
|
15 | 11 | - `header` (banner) |
16 | | -- `footer` (contentinfo) |
17 | 12 | - `main` (main) |
18 | | -- `nav` (navigation) |
19 | 13 | - `aside` (complementary) |
20 | | -- `section` (region) |
21 | 14 | - `form` (form, search) |
| 15 | +- `nav` (navigation) |
| 16 | +- `footer` (contentinfo) |
22 | 17 |
|
23 | 18 | ## Examples |
24 | 19 |
|
25 | | -Examples of **incorrect** code for this rule: |
| 20 | +This rule **forbids** the following: |
26 | 21 |
|
27 | | -```gjs |
28 | | -<template> |
29 | | - <nav>Primary Navigation</nav> |
30 | | - <nav>Secondary Navigation</nav> |
31 | | -</template> |
| 22 | +```hbs |
| 23 | +<nav></nav> |
| 24 | +<nav></nav> |
32 | 25 | ``` |
33 | 26 |
|
34 | | -```gjs |
35 | | -<template> |
36 | | - <header>Site Header</header> |
37 | | - <header>Article Header</header> |
38 | | -</template> |
| 27 | +```hbs |
| 28 | +<nav></nav> |
| 29 | +<div role='navigation'></div> |
39 | 30 | ``` |
40 | 31 |
|
41 | | -Examples of **correct** code for this rule: |
| 32 | +```hbs |
| 33 | +<nav aria-label='site navigation'></nav> |
| 34 | +<nav aria-label='site navigation'></nav> |
| 35 | +``` |
| 36 | + |
| 37 | +```hbs |
| 38 | +<form aria-label='search-form'></form> |
| 39 | +<form aria-label='search-form'></form> |
| 40 | +``` |
| 41 | + |
| 42 | +This rule **allows** the following: |
| 43 | + |
| 44 | +```hbs |
| 45 | +<nav aria-label='primary site navigation'></nav> |
| 46 | +<nav aria-label='secondary site navigation within home page'></nav> |
| 47 | +``` |
42 | 48 |
|
43 | | -```gjs |
44 | | -<template> |
45 | | - <nav aria-label="Primary Navigation">Links</nav> |
46 | | - <nav aria-label="Secondary Navigation">More Links</nav> |
47 | | -</template> |
| 49 | +```hbs |
| 50 | +<nav aria-label='primary site navigation'></nav> |
| 51 | +<div role='navigation' aria-label='secondary site navigation within home page'></div> |
48 | 52 | ``` |
49 | 53 |
|
50 | | -```gjs |
51 | | -<template> |
52 | | - <header aria-label="Site Header">Site Logo</header> |
53 | | - <header aria-label="Article Header">Article Title</header> |
54 | | -</template> |
| 54 | +```hbs |
| 55 | +<form aria-label='shipping address'></form> |
| 56 | +<form aria-label='billing address'></form> |
55 | 57 | ``` |
56 | 58 |
|
57 | | -```gjs |
58 | | -<template> |
59 | | - <nav aria-labelledby="nav-1"> |
60 | | - <h2 id="nav-1">Main Menu</h2> |
61 | | - </nav> |
62 | | - <nav aria-labelledby="nav-2"> |
63 | | - <h2 id="nav-2">Side Menu</h2> |
64 | | - </nav> |
65 | | -</template> |
| 59 | +```hbs |
| 60 | +<form role='search' aria-label='search'></form> |
| 61 | +<form aria-labelledby='form-title'><div id='form-title'>Meaningful Form Title</div></form> |
66 | 62 | ``` |
67 | 63 |
|
68 | 64 | ## References |
69 | 65 |
|
70 | | -- [ARIA Landmarks](https://www.w3.org/WAI/ARIA/apg/practices/landmark-regions/) |
71 | | -- [eslint-plugin-ember template-no-duplicate-landmark-elements](https://github.com/ember-cli/eslint-plugin-ember/blob/master/docs/rules/template-no-duplicate-landmark-elements.md) |
| 66 | +- [WAI-ARIA specification: Landmark Roles](https://www.w3.org/WAI/PF/aria/roles#landmark_roles) |
| 67 | +- [Understanding Success Criterion 1.3.1: Info and Relationships](https://www.w3.org/WAI/WCAG21/Understanding/info-and-relationships.html) |
| 68 | +- [Using aria-labelledby to name regions and landmarks](https://www.w3.org/WAI/WCAG21/Techniques/aria/ARIA13.html) |
| 69 | +- [Using aria-label to provide labels for objects](https://www.w3.org/WAI/WCAG21/Techniques/aria/ARIA6) |
0 commit comments