-
Notifications
You must be signed in to change notification settings - Fork 78
New rule: Explicit role SVG image has accessible name (7d6734) #419
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
Changes from all commits
e65a376
0935c3f
0311bb6
5ed1eb0
f20c215
55dfa2a
bf23111
817228b
5d5ca37
dad0355
067be4c
2f213a1
e42859f
3cc2f55
801fd64
96a861c
7799a15
ad33650
d956363
fa56eea
5e9710e
668ce46
b88c70d
aed615b
ec690c0
34f9099
4b65ad8
85248be
3a3a311
b573d82
04befe9
e2a0260
3914d55
0024ac9
93e658e
c51993e
746afe9
ba7a786
01aed67
5bacf1f
1b6dd27
dacae08
51515d1
5cb80e5
56e6d3f
4d17154
6a14a2e
fc54e21
707bd3b
a355c52
53afb1c
d5e1837
5ee8184
41bca24
eb6906d
5ebeb06
a466a54
596b78f
8010531
6c9ab22
e94b821
fa164a3
17176df
9a985c1
4cca85b
ab4c29f
93009e4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,180 @@ | ||
--- | ||
id: 7d6734 | ||
name: '`svg` element with explicit role has accessible name' | ||
rule_type: atomic | ||
description: | | ||
This rule checks that each SVG image element that is explicitly included in the accessibility tree has an accessible name. | ||
accessibility_requirements: | ||
wcag20:1.1.1: # Non-Text Content (A) | ||
forConformance: true | ||
failed: not satisfied | ||
passed: further testing needed | ||
inapplicable: further testing needed | ||
input_aspects: | ||
- DOM Tree | ||
- CSS Styling | ||
acknowledgements: | ||
authors: | ||
- Bryn Anderson | ||
--- | ||
|
||
## Applicability | ||
|
||
The rule applies to any element in the [SVG](https://www.w3.org/2000/svg) namespace with an [explicit semantic role](#explicit-semantic-role) of either `img`, `graphics-document`, `graphics-symbol`, that is [included in the accessibility tree](#included-in-the-accessibility-tree). | ||
|
||
**Note**: The [SVG Accessibility API Mappings](https://www.w3.org/TR/svg-aam-1.0/#include_elements) specifies that many elements in the SVG namespace are purely presentational and should not be included in the accessibility tree unless indicated otherwise through the use of text alternative content, an explicit WAI ARIA role, or a valid `tabindex` attribute. | ||
|
||
## Expectation | ||
|
||
Each target element has an [accessible name](#accessible-name) that is not empty. | ||
|
||
## Assumptions | ||
|
||
This rule assumes that the presence of one of the roles outlined in the applicability indicates the authors intent to include the element in the accessibility tree and thus convey information to the user about that element. | ||
|
||
## Accessibility Support | ||
|
||
The [HTML Accessibility API Mappings](https://www.w3.org/TR/html-aam-1.0/#html-element-role-mappings) specify that the `<svg>` element has an implicit role of `graphics-document`. However browser support for the `graphics-document` role and the [SVG Accessibility API Mappings](https://www.w3.org/TR/svg-aam-1.0) is inconsistent. | ||
|
||
This rule is limited to the explicit use of roles, as a clear indication that content should convey meaning, until the [SVG Accessibility API Mappings](https://www.w3.org/TR/svg-aam-1.0) is more stable and browser support is more consistent. | ||
|
||
Browser and assistive technology support for SVG `<title>` and `<desc>` elements is currently inconsistent. Using WAI ARIA in combination with the `img` role for non-decorative `<svg>` elements significantly improves accessibility browser support. | ||
|
||
Until browser support for the [SVG Accessibility API Mappings](https://www.w3.org/TR/svg-aam-1.0) is more consistent it is recommended to explicitly remove decorative <svg> elements from the accessibility tree. | ||
|
||
## Background | ||
|
||
- [Understanding Success Criterion 1.1.1: Non-text Content](https://www.w3.org/WAI/WCAG21/Understanding/non-text-content.html) | ||
- [SVG Accessibility API Mappings (working draft)](https://www.w3.org/TR/svg-aam-1.0) | ||
- [WAI-ARIA Graphics Module](https://www.w3.org/TR/graphics-aria-1.0/) | ||
- [ARIA4: Using a WAI-ARIA role to expose the role of a user interface component](https://www.w3.org/WAI/WCAG21/Techniques/aria/ARIA4) | ||
- [ARIA6: Using aria-label to provide labels for objects](https://www.w3.org/WAI/WCAG21/Techniques/aria/ARIA6) | ||
- [ARIA10: Using aria-labelledby to provide a text alternative for non-text content](https://www.w3.org/WAI/WCAG21/Techniques/aria/ARIA10) | ||
|
||
## Test Cases | ||
Brynanders marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
### Passed | ||
Brynanders marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
#### Passed Example 1 | ||
|
||
The `svg` element has an explicit role of `img` and an accessible name from the `title` element that is not empty. | ||
|
||
```html | ||
<p>How many circles are there?</p> | ||
<svg xmlns="http://www.w3.org/2000/svg" role="img" width="100" height="100"> | ||
<title>1 circle</title> | ||
<circle cx="50" cy="50" r="40" fill="yellow"></circle> | ||
</svg> | ||
``` | ||
|
||
#### Passed Example 2 | ||
|
||
The `circle` element has an explicit role of `graphics-symbol` and an accessible name from the `aria-label` attribute that is not empty. | ||
|
||
```html | ||
<p>How many circles are there?</p> | ||
<svg xmlns="https://www.w3.org/2000/svg"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What w3c spec is being used to define the accessible name calculation for this SVG? From my reading of the note in:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ahh, that makes more sense. So we are not testing the outer SVG element but just the inner circle element. I guess when I read the rule title saying an "…SVG image has accessible name", I thought all the tests were for the SVG element. Many of the test cases are for the SVG elements. Maybe this should be split up for SVG elements and children of SVG elements. Anyway, thanks for clarifying. |
||
<circle | ||
role="graphics-symbol" | ||
cx="50" | ||
cy="50" | ||
r="40" | ||
stroke="green" | ||
stroke-width="4" | ||
fill="yellow" | ||
aria-label="1 circle" | ||
></circle> | ||
</svg> | ||
EmmaJP marked this conversation as resolved.
Show resolved
Hide resolved
|
||
``` | ||
|
||
#### Passed Example 3 | ||
|
||
The `svg` element has an explicit role of `graphics-document` and an accessible name from the `title` element that is not empty. | ||
|
||
```html | ||
<p>How many circles are there?</p> | ||
<svg xmlns="http://www.w3.org/2000/svg" role="graphics-document" width="100" height="100"> | ||
<title>1 circle</title> | ||
<circle cx="50" cy="50" r="40" fill="yellow"></circle> | ||
</svg> | ||
``` | ||
|
||
### Failed | ||
|
||
#### Failed Example 1 | ||
|
||
The `svg` element has an explicit role of `img` but has no accessible name. | ||
|
||
```html | ||
<p>How many circles are there?</p> | ||
<svg xmlns="http://www.w3.org/2000/svg" role="img"> | ||
<circle cx="50" cy="50" r="40" stroke="green" stroke-width="4" fill="yellow"></circle> | ||
</svg> | ||
``` | ||
|
||
#### Failed Example 2 | ||
|
||
The `svg` element has an explicit role of `img` but has only whitespace in the `title` element for the accessible name. | ||
|
||
```html | ||
<p>How many circles are there?</p> | ||
<svg xmlns="http://www.w3.org/2000/svg" role="img"> | ||
<title></title> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just a note that this example does not have whitespace within the title element as per the description. It is identical code to Failed Example 3. |
||
<circle cx="50" cy="50" r="40" fill="yellow"></circle> | ||
</svg> | ||
``` | ||
|
||
#### Failed Example 3 | ||
|
||
The `svg` element has an explicit role of `img`, is included in the accessibility tree, but it has no accessible name because the `title` element is empty. | ||
|
||
```html | ||
<p>How many circles are there?</p> | ||
<svg xmlns="http://www.w3.org/2000/svg" role="img"> | ||
<title></title> | ||
<circle cx="50" cy="50" r="40" fill="yellow"></circle> | ||
</svg> | ||
``` | ||
|
||
#### Failed Example 4 | ||
|
||
The `circle` element has an explicit role of `graphics-symbol` but does not have an accessible name. | ||
|
||
```html | ||
<p>How many circles are there?</p> | ||
<svg xmlns="http://www.w3.org/2000/svg"> | ||
<circle role="graphics-symbol" cx="50" cy="50" r="40" stroke="green" stroke-width="4" fill="yellow"></circle> | ||
</svg> | ||
``` | ||
|
||
### Inapplicable | ||
|
||
#### Inapplicable Example 1 | ||
Jym77 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
Both the `svg` and `circle` elements do not have an explicit role. | ||
|
||
```html | ||
<svg xmlns="http://www.w3.org/2000/svg"> | ||
<circle cx="50" cy="50" r="40" fill="yellow"></circle> | ||
</svg> | ||
``` | ||
|
||
#### Inapplicable Example 2 | ||
|
||
The `svg` element has an explicit role of `img` but the `aria-hidden` attribute removes the element and its descendants from the accessibility tree. | ||
Brynanders marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
```html | ||
<svg xmlns="http://www.w3.org/2000/svg" role="img" aria-hidden="true"> | ||
<circle cx="50" cy="50" r="40" fill="yellow"></circle> | ||
</svg> | ||
``` | ||
|
||
#### Inapplicable Example 3 | ||
|
||
The `circle` element has an explicit role that is neither `img`, `graphics-document` or `graphics-symbol`. | ||
|
||
```html | ||
<svg xmlns="http://www.w3.org/2000/svg"> | ||
<circle role="graphics-object" cx="50" cy="50" r="40" fill="yellow"></circle> | ||
</svg> | ||
``` |
Uh oh!
There was an error while loading. Please reload this page.