Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rule: ARIA required context role (ff89c9) #255

Merged
merged 74 commits into from
Nov 25, 2019
Merged
Show file tree
Hide file tree
Changes from 61 commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
4b2cd9a
Create SC1-3-1-aria-required-context-role.md
Sep 14, 2018
bdbfbeb
Update SC1-3-1-aria-required-context-role.md
Sep 15, 2018
f80607d
Editorial update per feedback
Oct 3, 2018
409bb9a
Removed test case per feedback
Oct 3, 2018
8f79ac6
Update to Accessibility Support
Oct 3, 2018
4f4701d
Cleaner WAI-ARIA references
Oct 5, 2018
7b43dde
Editorials per feedback from Kasper
Oct 18, 2018
2ac617f
Create owner-element.md
Jan 22, 2019
ded2be6
Update owner-element.md
Jan 22, 2019
8a81b50
Update rule to use new Owner element definition
Jan 22, 2019
1542f48
Update owner-element.md
Jan 22, 2019
b9b79a8
chore: merge from master
jeeyyy Jan 22, 2019
8bf6038
Update included-in-the-accessibility-tree.md
Jan 22, 2019
dfc56b2
Update owner-element.md
Jan 22, 2019
c2ccbc1
Removed role="none"/"presentation"
Jan 22, 2019
35d480e
Updated test cases to match new definitions
Jan 22, 2019
9835b44
Add note about divergence from WAI-ARIA spec
Jan 22, 2019
d92d89c
Update SC1-3-1-aria-required-context-role.md
Jan 22, 2019
16f50c7
Editorials
Jan 22, 2019
47e4ce5
`aria-owns` support added to Accessibility Support
Feb 12, 2019
96472af
Test case moved from Failed to Inapplicable
Feb 12, 2019
0785f09
Changed "element" to "node"
Feb 12, 2019
9c81dcd
Disclaimer notes inserted
Feb 12, 2019
52a4b1e
Note added on hiding elements
Feb 12, 2019
4339973
Editorials per Wilco's comments
Mar 5, 2019
5c7b137
Updating to account for competing owned elements
Mar 6, 2019
127beb4
Adding links to definitions
Mar 6, 2019
473016f
Added link to definition
Mar 6, 2019
b952555
Rule updated to use new "owned by" definition
Mar 6, 2019
dc50845
Reverting changes to "included in the acc. tree"
Mar 6, 2019
542090d
Added inapplicable test case
Mar 6, 2019
31a7bf1
Added Passed test case
Mar 7, 2019
576eb0d
New assumption: role being used to comply to WCAG
Mar 7, 2019
c031c89
Further elaboration of assumption
Mar 7, 2019
8d08752
Editorials per Kasper's comments
Mar 21, 2019
08069fa
Fix incorrect code and descriptions in test cases
Apr 23, 2019
7578413
Accessibility Support note on empty elements
Apr 23, 2019
b360785
Editorial: Slight rewording of Expectation
May 1, 2019
4b13b65
Add id to frontmatter of rule
May 1, 2019
922d3e8
Update template + editorials + note for Appl.
Jun 7, 2019
33d0f44
Now tree-crossing ownership for implicit ownership
Jun 12, 2019
e9f8a8a
Added test cases crossing shadow boundaries
Jun 12, 2019
1a6d693
Extended description for shadow DOM test cases
Jun 13, 2019
9a6da41
Update SC1-3-1-aria-required-context-role.md
Brynanders Jul 3, 2019
6839767
Merge branch 'develop' into sc1-3-1-aria-required-context-role
jeeyyy Jul 3, 2019
376ce5f
Editorials
Jul 10, 2019
9b73e57
Editorial: plural for consistency
Jul 12, 2019
87777d3
Change test case description to match test case
Jul 12, 2019
476a2e6
Merge branch 'develop' into sc1-3-1-aria-required-context-role
jeeyyy Jul 17, 2019
4ff8e00
Rename SC1-3-1-aria-required-context-role.md to aria-required-context…
jeeyyy Jul 17, 2019
b7e25e0
Insert link to Understanding 1.3.1 document
Jul 18, 2019
c41e314
Add example to Appl. + change definition links
Jul 26, 2019
78169f8
Remove `slot` element from Passed Example 6
Jul 26, 2019
ee977ac
Add content to elements + Add new test case
Jul 26, 2019
c41dfe3
More links to "explicit-role" def. + fix typo
Aug 5, 2019
8f62229
Expectation: Note on superclass/subclass roles
Aug 6, 2019
32b92de
Edit subclass inclusion in required context roles
Aug 13, 2019
07ba91a
Add note about descoping DPUB from applicability
Aug 13, 2019
191b5cc
Adding inapplicable DPUB test case
Aug 14, 2019
c4e760e
Merge branch 'develop' into sc1-3-1-aria-required-context-role
jeeyyy Aug 14, 2019
f152e32
chore: merge from develop
jeeyyy Aug 14, 2019
8262e3a
Rename owner-element.md to owned-by.md
Aug 16, 2019
4efedba
Remove note + inclusion i acc. tree for point 1
Aug 16, 2019
1af2679
Editorials + change test cases
Aug 16, 2019
45f5648
Changing Passed Example 5 to pass SC 1.3.1
Aug 21, 2019
ca84d89
Merge branch 'develop' into sc1-3-1-aria-required-context-role
WilcoFiers Sep 25, 2019
89aee3c
Merge branch 'develop' into sc1-3-1-aria-required-context-role
Jym77 Oct 18, 2019
f4f5188
chore: update rule to use accessibility tree as input
WilcoFiers Nov 1, 2019
5b45798
Merge branch 'develop' into sc1-3-1-aria-required-context-role
WilcoFiers Nov 1, 2019
e3db62e
chore: fix failing tests
WilcoFiers Nov 1, 2019
5cbc373
Apply suggestions from code review
WilcoFiers Nov 13, 2019
7362c00
Merge branch 'develop' into sc1-3-1-aria-required-context-role
WilcoFiers Nov 13, 2019
5db02eb
Update aria-required-context-role-ff89c9.md
WilcoFiers Nov 13, 2019
b8519e1
Merge branch 'develop' into sc1-3-1-aria-required-context-role
jeeyyy Nov 20, 2019
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
284 changes: 284 additions & 0 deletions _rules/aria-required-context-role-ff89c9.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,284 @@
---
id: ff89c9
name: ARIA required context role
rule_type: atomic
description: |
This rule checks that a role exists inside its required context.
annethyme marked this conversation as resolved.
Show resolved Hide resolved
accessibility_requirements:
wcag20:1.3.1: # Info and Relationships (A)
forConformance: true
failed: not satisfied
passed: further testing needed
inapplicable: further testing needed
input_aspects:
- DOM Tree
- CSS Styling
authors:
- Anne Thyme Nørregaard
---

## Applicability

The rule applies to any HTML or SVG element that is [included in the accessibility tree](#included-in-the-accessibility-tree) and has a [WAI-ARIA 1.1](https://www.w3.org/TR/wai-aria-1.1/) [explicit semantic role](#explicit-role) with a [WAI-ARIA required context role](https://www.w3.org/TR/wai-aria-1.1/#scope), except if the element has an [implicit semantic role](#implicit-role) that is identical to its [explicit semantic role](#explicit-role).
annethyme marked this conversation as resolved.
Show resolved Hide resolved
Jym77 marked this conversation as resolved.
Show resolved Hide resolved

**Note:** An example of an element that has a [WAI-ARIA required context role](https://www.w3.org/TR/wai-aria-1.1/#scope) is `tab` that has `tablist` as a [required context role](https://www.w3.org/TR/wai-aria-1.1/#scope).

**Note:** An example of an element that has an [implicit semantic role](#implicit-role) that is identical to its [explicit semantic role](#explicit-role) is an `<li>` element that has `role="listitem"`. This rule is not applicable to elements like this.

**Note:** The applicability of this rule is limited to only the [WAI-ARIA 1.1 Recommendation](https://www.w3.org/TR/wai-aria-1.1/), since inheritance of [required context roles](https://www.w3.org/TR/wai-aria-1.1/#scope) to [subclass roles](https://www.w3.org/TR/wai-aria-1.1/#subclassroles) seems to work differently within the [Digital Publishing WAI-ARIA Module 1.0](https://www.w3.org/TR/dpub-aria-1.0/) extension than within the [WAI-ARIA 1.1 Recommendation](https://www.w3.org/TR/wai-aria-1.1/) itself. The [WAI-ARIA Graphics Module](https://www.w3.org/TR/graphics-aria-1.0/) does not include any [required context roles](https://www.w3.org/TR/wai-aria-1.1/#scope).
annethyme marked this conversation as resolved.
Show resolved Hide resolved

## Expectation

The target element is [owned by](#owned-by) an element that has a [semantic role](#semantic-role) that is one of the [WAI-ARIA required context roles](https://www.w3.org/TR/wai-aria-1.1/#scope) of the target element.
WilcoFiers marked this conversation as resolved.
Show resolved Hide resolved

**Note:** The definition of [owned by](#owned-by) used in this rule is diverging from the definition of ["owned element" in WAI-ARIA](https://www.w3.org/TR/wai-aria-1.1/#dfn-owned-element). See more in the [owned by](#owned-by) definition.
Copy link
Member

Choose a reason for hiding this comment

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

"is diverging from" -> "is different than"


**Note:** [Subclass roles](https://www.w3.org/TR/wai-aria-1.1/#subclassroles) of [WAI-ARIA required context roles](https://www.w3.org/TR/wai-aria-1.1/#scope) are not automatically included as possible [required context roles](https://www.w3.org/TR/wai-aria-1.1/#scope). E.g. the [`feed`](https://www.w3.org/TR/wai-aria-1.1/#feed) role is not a possible [required context role](https://www.w3.org/TR/wai-aria-1.1/#scope) for [`listitem`](https://www.w3.org/TR/wai-aria-1.1/#listitem), even though [`feed`](https://www.w3.org/TR/wai-aria-1.1/#feed) is a [subclass role](https://www.w3.org/TR/wai-aria-1.1/#subclassroles) of the [`list`](https://www.w3.org/TR/wai-aria-1.1/#list) role, and [`list`](https://www.w3.org/TR/wai-aria-1.1/#list) is one of the [required context roles](https://www.w3.org/TR/wai-aria-1.1/#scope) for [`listitem`](https://www.w3.org/TR/wai-aria-1.1/#listitem).
If a [subclass role](https://www.w3.org/TR/wai-aria-1.1/#subclassroles) is a possible [required context role](https://www.w3.org/TR/wai-aria-1.1/#scope), the [subclass role](https://www.w3.org/TR/wai-aria-1.1/#subclassroles) will be listed as a [required context role](https://www.w3.org/TR/wai-aria-1.1/#scope) as well as the [superclass role](https://www.w3.org/TR/wai-aria-1.1/#superclassrole), e.g. the [`row`](https://www.w3.org/TR/wai-aria-1.1/#row) role lists both [`grid`](https://www.w3.org/TR/wai-aria-1.1/#grid) and [`table`](https://www.w3.org/TR/wai-aria-1.1/#table) as [required context roles](https://www.w3.org/TR/wai-aria-1.1/#scope), even though [`grid`](https://www.w3.org/TR/wai-aria-1.1/#grid) is a subclass of the [`table`](https://www.w3.org/TR/wai-aria-1.1/#table) role.

**Note:** For [`listitem` (role)](https://www.w3.org/TR/wai-aria-1.1/#listitem) the [`directory` (role)](https://www.w3.org/TR/wai-aria-1.1/#directory) seems to be missing as a [required context role](https://www.w3.org/TR/wai-aria-1.1/#scope) in the [WAI-ARIA 1.1 Recommendation](https://www.w3.org/TR/wai-aria-1.1). [An issue for this has been filed](https://github.com/w3c/aria/issues/1030) with the Accessible Rich Internet Applications Working Group.


annethyme marked this conversation as resolved.
Show resolved Hide resolved
## Assumptions

This rule assumes that the [explicit semantic role](#explicit-role) on the target element is used with the intention to comply to WCAG. If the [explicit semantic role](#explicit-role) on the target element is incorrectly used, and any relationships between elements are already programmatically determinable, failing this rule might 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.
annethyme marked this conversation as resolved.
Show resolved Hide resolved

## Accessibility Support

- This rule relies on assistive technologies to recognize which elements are [owned by](#owned-by) each other. This includes when the element is owned by another element that is an ancestor, but not a parent of the target element. Some assistive technologies do not accept these owned by relationships, unless workarounds are used.
Copy link
Member

Choose a reason for hiding this comment

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

I'd rephrase this. You're essentially saying that elements own each other. That's not right. I would say replace "recognise which elements are owned by each other" with "consistently identify which element [owns] which other element."

Furthermore, `aria-owns` has limited support in some user agents.
annethyme marked this conversation as resolved.
Show resolved Hide resolved
- Some user agents and assistive technologies ignore empty elements, which means they are not presented to all users. However, since this is handled inconsitently across user agents and assistive technologies, this rule is applicable to empty elements.

## Background

- [Understanding Success Criterion 1.3.1: Info and Relationships](https://www.w3.org/WAI/WCAG21/Understanding/info-and-relationships.html)
- [Required Context Role](https://www.w3.org/TR/wai-aria-1.1/#scope)

This comment was marked as resolved.

This comment was marked as resolved.


## Test Cases

### Passed

This comment was marked as resolved.

This comment was marked as resolved.

Jym77 marked this conversation as resolved.
Show resolved Hide resolved

#### Passed Example 1

Element with role `listitem` is contained within its required context role `list`, expressed as an explicit role.

```html
<div role="list">
<div role="listitem">List item 1</div>
</div>
```

#### Passed Example 2

Element with role `listitem` is contained within its required context role `list`, through the implicit role of `ul`.

```html
<ul>
<div role="listitem">List item 1</div>
</ul>
```

#### Passed Example 3

Element contained within its required context role even though it is not a direct child of the context role.

```html
<div role="list">
<div>
<div>
<div>
<div role="listitem">List item 1</div>
</div>
</div>
</div>
</div>
```

#### Passed Example 4

`aria-owns` used to give the target element the right context role.

```html
<div role="list" aria-owns="id1"></div>
WilcoFiers marked this conversation as resolved.
Show resolved Hide resolved
<div id="id1" role="listitem">List item 1</div>
WilcoFiers marked this conversation as resolved.
Show resolved Hide resolved
```

#### Passed Example 5
Jym77 marked this conversation as resolved.
Show resolved Hide resolved

`aria-owns` trumps ownership by closest ancestor, giving the element with role of `listitem` the correct context role.

```html
<div role="list" aria-owns="id1">
WilcoFiers marked this conversation as resolved.
Show resolved Hide resolved
<div role="tabpanel">
<div id="id1" role="listitem">List item 1</div>
</div>
</div>
```

#### Passed Example 6

Since implicit ownership can cross shadow boundaries, the element with the semantic role of `listitem` is contained within its required context role `list`.

```html
<div id="host" role="list">
</div>

<script>
const host = document.querySelector("#host");
const root = host.attachShadow({ mode: "open" });

root.innerHTML = `
<div role="listitem">List item 1</div>
`;
</script>
```
#### Passed Example 7

Element with role `listitem` is contained within its required context role `list`, expressed as an explicit role. Even though the element with role `listitem` is empty, it is still applicable to this rule.

```html
<div role="list">
<div role="listitem"></div>
</div>
```

### Failed

#### Failed Example 1

No context role.

```html
<div role="listitem">List item 1</div>
```

#### Failed Example 2

Wrong context role.

```html
<div role="tablist">
<div role="listitem">List item 1</div>
</div>
```

#### Failed Example 3

Element not contained within its required context role.

```html
<div role="list"></div>
<div role="listitem">List item 1</div>
annethyme marked this conversation as resolved.
Show resolved Hide resolved
```

#### Failed Example 4

Element with role `listitem` has a closer ancestor, that is included in the accessibility tree, than the role `list` that should have been its context role.

```html
<div role="list">
<div aria-label="menu">
<div role="listitem">List item 1</div>
</div>
</div>
```

**Note:** This test case follows the definition of [owned by](#owned-by) used in this rule. If implemented differently, this definition could cause differences in outcome for this test case.


#### Failed Example 5

Element with role `listitem` has a closer ancestor, that is included in the accessibility tree, than the role `list` that should have been its context role.
annethyme marked this conversation as resolved.
Show resolved Hide resolved

```html
<div role="list">
<div role="tabpanel">
<div role="listitem">List item 1</div>
</div>
</div>
annethyme marked this conversation as resolved.
Show resolved Hide resolved
```

#### Failed Example 6

The element with the semantic role of `listitem` is [owned by](#owned-by) the first element that references it through `aria-owns`, which results in the wrong context role.
annethyme marked this conversation as resolved.
Show resolved Hide resolved

```html
<div role="tabpanel" aria-owns="id1">
<div role="list" aria-owns="id1">
<div id="id1" role="listitem">List item 1</div>
</div>
</div>
```

**Note:** This test case follows the definition of [owned by](#owned-by) used in this rule. If implemented differently, this definition could cause differences in outcome for this test case.

#### Failed Example 7

Since explicit ownership cannot cross shadow boundaries, the element with the semantic role of `listitem` does not have a context role.

```html
<div role="list" aria-owns="item">
</div>

<div id="host"></div>

<script>
const host = document.querySelector("#host");
const root = host.attachShadow({ mode: "open" });

root.innerHTML = `
<div id="item" role="listitem">List item 1</div>
`;
</script>
```

### Inapplicable

#### Inapplicable Example 1

Element does not have an explicit semantic role.

```html
<ul>List item 1</ul>
Copy link
Member

Choose a reason for hiding this comment

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

Can you have this not fail SC 1.3.1?

```

#### Inapplicable example 2

Element is not exposed to assistive technologies.

```html
<div role="listitem" aria-hidden="true">List item 1</div>
```

#### Inapplicable Example 3

Role does not have any required context roles listed in WAI-ARIA spec.

```html
<div role="radio">Radio button 1</div>
```

#### Inapplicable Example 4

Element is not exposed to assistive technologies, since ancestor has `aria-hidden` attribute with value set to `true`.

```html
<div role="list" aria-hidden="true">
<div role="listitem">List item 1</div>
</div>
```
#### Inapplicable Example 5

Element has an explicit semantic role, but it is identical to the implicit semantic role, making the element inapplicable.

```html
<li role="listitem">List item 1</li>
```

#### Inapplicable Example 6

Element has a role from the [Digital Publishing WAI-ARIA Module 1.0](https://www.w3.org/TR/dpub-aria-1.0/), not the [WAI-ARIA 1.1 Recommendation](https://www.w3.org/TR/wai-aria-1.1/), and it is therefore inapplicable.

```html
<div role="doc-bibliography">Item 1<div>
annethyme marked this conversation as resolved.
Show resolved Hide resolved
```
2 changes: 1 addition & 1 deletion pages/glossary/included-in-the-accessibility-tree.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ Elements included in the accessibility tree of platform specific accessibility A

The general rules for when elements are included in the accessibility tree are defined in the [core accessibility API mappings](https://www.w3.org/TR/core-aam/). For native markup languages, such as HTML and SVG, additional rules for when elements are included in the accessibility tree can be found in the [HTML accessibility API mappings](https://www.w3.org/TR/html-aam/) (work in progress) and the [SVG accessibility API mappings](https://www.w3.org/TR/svg-aam/) (work in progress).

> **Note:** Users of assistive technologies might still be able to interact with elements that are not included in the accessibility tree. An example of this is a [focusable](#focusable) element with an `aria-hidden` attribute with a value of `true`. Such an element could still be interacted with using sequential keyboard navigation regardless of the assistive technologies used, even though the element would not be included in the accessibility tree.
> **Note:** Users of assistive technologies might still be able to interact with elements that are not included in the accessibility tree. An example of this is a [focusable](#focusable) element with an `aria-hidden` attribute with a value of `true`. Such an element could still be interacted with using sequential keyboard navigation regardless of the assistive technologies used, even though the element would not be included in the accessibility tree.
15 changes: 15 additions & 0 deletions pages/glossary/owner-element.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
Copy link
Collaborator

Choose a reason for hiding this comment

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

ideally the file name should be owned-by.md

title: Owned by
key: owned-by
---

An element A is owned by element B if:

1. Both elements exist within the same [document tree](https://www.w3.org/TR/dom41/#document-trees) or [shadow tree](https://www.w3.org/TR/dom41/#shadow-trees), and element A is the first element within the tree, in [tree order](https://www.w3.org/TR/dom/#concept-tree-order), whose ID is included within the `aria-owns` attribute of element B, or
2. Element B is the closest [shadow including ancestor](https://www.w3.org/TR/dom41/#concept-shadow-including-ancestor) of element A that is [included in the accessibility tree](#included-in-the-accessibility-tree).

Nodes that are not included in the accessibility tree cannot be owned by other elements.

> **Note:** When using `aria-owns`, hiding the owner element through WAI-ARIA (`aria-hidden="true"`) or CSS (`display:none` or `visibility:hidden`) will not change the ownership, but should instead hide all elements owned by the element.
Copy link
Member

Choose a reason for hiding this comment

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

This contradicts your point 1 and 2. I also don't think this is intuitive, and it doesn't seem to be how it is currently implemented. I would guess this is unlikely to ever become standardised.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@WilcoFiers,

This part of your comment:

I also don't think this is intuitive, and it doesn't seem to be how it is currently implemented. I would guess this is unlikely to ever become standardised.

... is that for the note or for the entire definition of "owned by"?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

"Owned by" definition has been slightly rewritten and note removed.

Can I have you review again and say if you agree?


> **Note:** This definition is diverging from the definition of ["owned element" in WAI-ARIA](https://www.w3.org/TR/wai-aria-1.1/#dfn-owned-element). The reason is that the WAI-ARIA definition was found to provide too little guidance on how to handle specific edge cases where several elements compete about the ownership, and it seem that browser implementations of this are diverging a lot. This definition seeks to find a reasonable middle ground, but will have to be updated if the WAI-ARIA definition changes.