Skip to content

Commit 794ed26

Browse files
shunguoyWilcoFiers
andauthored
Update the aria-required-owned rule [bc4a75] to include the elements with implicit roles (#2318)
* update the examples for aria-required-owned rule * update the test cases * fix syntax errors * remove implicit/explicit from the description Co-authored-by: Wilco Fiers <[email protected]> * add more Pass and Fail test cases * fix formatting issue * add more test cases * update the test cases * remove unused explcit_semantic_role * Add one more Failed example --------- Co-authored-by: Wilco Fiers <[email protected]>
1 parent d549cb2 commit 794ed26

File tree

1 file changed

+97
-11
lines changed

1 file changed

+97
-11
lines changed

_rules/aria-required-owned-element-bc4a75.md

Lines changed: 97 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ name: ARIA required owned elements
44
rules_format: 1.1
55
rule_type: atomic
66
description: |
7-
This rule checks that an element with an explicit role that restricts which elements it can own only owns such elements.
7+
This rule checks that an element with a semantic role that restricts which elements it can own only owns such elements.
88
accessibility_requirements:
99
wcag20:1.3.1: # Info and Relationships (A)
1010
forConformance: true
@@ -27,7 +27,7 @@ acknowledgments:
2727

2828
## Applicability
2929

30-
This rule applies to any [HTML or SVG element][] that is [included in the accessibility tree][] and has a [WAI-ARIA 1.2][] [explicit semantic role][] with [required owned elements][], except if the element has an [inclusive ancestor][] in the accessibility tree with an `aria-busy` [attribute value][] of `true`.
30+
This rule applies to any [HTML or SVG element][] that is [included in the accessibility tree][] and has a [WAI-ARIA 1.2][] [semantic role][] with [required owned elements][], except if the element has an [inclusive ancestor][] in the accessibility tree with an `aria-busy` [attribute value][] of `true`.
3131

3232
## Expectation
3333

@@ -45,7 +45,7 @@ The applicability of this rule is limited to the [WAI-ARIA 1.2 Recommendation][w
4545

4646
### Assumptions
4747

48-
If the [explicit semantic role][] on the target element is incorrectly used, and any relationships between elements are already programmatically determinable, failing this rule may not result in accessibility issues for users of assistive technologies, and it should then not be considered a failure under [WCAG success criterion 1.3.1 Info and Relationships](https://www.w3.org/TR/WCAG22/#info-and-relationships).
48+
If the [semantic role][] on the target element is incorrectly used, and any relationships between elements are already programmatically determinable, failing this rule may not result in accessibility issues for users of assistive technologies, and it should then not be considered a failure under [WCAG success criterion 1.3.1 Info and Relationships](https://www.w3.org/TR/WCAG22/#info-and-relationships).
4949

5050
### Accessibility Support
5151

@@ -93,16 +93,16 @@ This element with the `menu` role only owns elements with the `menuitem`, `menui
9393

9494
```html
9595
<div role="menu">
96-
<li role="none"></li>
97-
<li role="menuitem">Item 1</li>
96+
<div role="none"></div>
97+
<div role="menuitem">Item 1</div>
9898
<div role="menuitemradio" aria-checked="false">Item 2</div>
9999
<div role="menuitemcheckbox" aria-checked="false">Item 3</div>
100100
</div>
101101
```
102102

103103
#### Passed Example 4
104104

105-
This element with the `tablist` role only owns elements with the `tab` role. The `tab` role is one of the [required owned elements][] for `tablist`. The `li` element is ignored because it has an [explicit semantic role][] of `none`.
105+
This element with the `tablist` role only owns elements with the `tab` role. The `tab` role is one of the [required owned elements][] for `tablist`. The `li` element is ignored because it has an [semantic role][] of `none`.
106106

107107
```html
108108
<ul role="tablist">
@@ -139,6 +139,56 @@ This element with the `menu` role only owns an element with a `group` role. The
139139
</div>
140140
```
141141

142+
#### Passed Example 7
143+
144+
The element `ul` with an implicit `list` role owns an element `li` with an implicit `listitem` role.
145+
146+
```html
147+
<ul>
148+
<li>Item 1</li>
149+
</ul>
150+
```
151+
152+
#### Passed Example 8
153+
154+
The element `select` with an implicit `listbox` role owns elements `option` with implicit `option` roles.
155+
156+
```html
157+
<select multiple>
158+
<option>Item 1</option>
159+
<option>Item 2</option>
160+
<option>Item 3</option>
161+
</select>
162+
```
163+
164+
#### Passed Example 9
165+
166+
The element `table` with an implicit `table` role owns an element `tr` with implicit `row` role that in turn owns elements `td` with implicit `cell` roles.
167+
168+
```html
169+
<table>
170+
<tr>
171+
<td>Item 1</td>
172+
<td>Item 2</td>
173+
<td>Item 3</td>
174+
</tr>
175+
</table>
176+
```
177+
178+
#### Passed Example 10
179+
180+
The element `table` with an explicit `treegrid` role owns an element `tr` with implicit `row` role that in turn owns elements `td` with implicit `gridcell` roles.
181+
182+
```html
183+
<table role="treegrid" aria-label="a test grid">
184+
<tr>
185+
<td>Item 1</td>
186+
<td>Item 2</td>
187+
<td>Item 3</td>
188+
</tr>
189+
</table>
190+
```
191+
142192
### Failed
143193

144194
#### Failed Example 1
@@ -225,6 +275,43 @@ This element with the `list` role owns an element with the `listitem` role and a
225275
</div>
226276
```
227277

278+
#### Failed Example 8
279+
280+
This element with the `menu` role owns `option` elements with implicit `option` role. The `option` role is not one of the [required owned elements][] for `menu`.
281+
282+
```html
283+
<select role="menu" aria-label="a test menu">
284+
<option>Item 1</option>
285+
<option>Item 2</option>
286+
<option>Item 3</option>
287+
</select>
288+
```
289+
290+
#### Failed Example 9
291+
292+
This element with the `menu` role owns `tr` elements with an explicit `list` role. The `list` role is not one of the [required owned elements][] for `menu`. In addition, the `tr` element with the explicit `list` role owns `td` elements with explicit `menuitem` roles. The `menuitem` role is not one of the [required owned elements][] for `list`.
293+
294+
```html
295+
<table role="menu" aria-label="a test table" aria-activedescendant="item1" tabindex="0">
296+
<tr role="list">
297+
<td id="item1" role="menuitem">Item 1</td>
298+
<td id="item2" role="menuitem">Item 2</td>
299+
<td id="item3" role="menuitem">Item 3</td>
300+
</tr>
301+
</table>
302+
```
303+
304+
#### Failed Example 10
305+
306+
This element with the implicit `list` role owns an element with the implicit `generic` role. The `generic` role is not one of the [required owned elements][] for `list`. Note that this example is for demonstration purpose only because it's not a valid HTML 5 structure.
307+
308+
```html
309+
<ul>
310+
<div></div>
311+
<div></div>
312+
</ul>
313+
```
314+
228315
### Inapplicable
229316

230317
#### Inapplicable Example 1
@@ -237,12 +324,12 @@ This element with the `list` role is not included in the accessibility tree beca
237324

238325
#### Inapplicable Example 2
239326

240-
This `ul` element does not have an [explicit semantic role][].
327+
This `div` element with the `list` role is not included in the accessibility tree because it is hidden .
241328

242329
```html
243-
<ul>
244-
<li>Item 1</li>
245-
</ul>
330+
<div role="list" hidden>
331+
<div role="listitem">Item 1</div>
332+
</div>
246333
```
247334

248335
#### Inapplicable Example 3
@@ -269,7 +356,6 @@ This element with the `menu` role has an `aria-busy` attribute set to `true`.
269356
[required owned elements]: https://www.w3.org/TR/wai-aria-1.2/#mustContain 'Define Required owned element'
270357
[owns]: #owned-by
271358
[owned by]: #owned-by
272-
[explicit semantic role]: #explicit-role
273359
[semantic role]: #semantic-role
274360
[included in the accessibility tree]: #included-in-the-accessibility-tree
275361
[wai-aria 1.2]: https://www.w3.org/TR/wai-aria-1.2/

0 commit comments

Comments
 (0)