Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
e65a376
Create SVG-image-has-name
Brynanders Feb 6, 2019
0935c3f
Update SVG-image-has-name
Brynanders Feb 26, 2019
0311bb6
Update SVG-image-has-name
Brynanders Mar 8, 2019
5ed1eb0
Update SVG-image-has-name
Brynanders Mar 12, 2019
f20c215
Update SVG-image-has-name
Brynanders Mar 12, 2019
55dfa2a
Update SVG-image-has-name
Brynanders Mar 20, 2019
bf23111
Update SVG-image-has-name
Brynanders Mar 20, 2019
817228b
Update SVG-image-has-name
Brynanders Mar 20, 2019
5d5ca37
Update SVG-image-has-name
Brynanders Mar 20, 2019
dad0355
Update SVG-image-has-name
Brynanders Mar 21, 2019
067be4c
Update SVG-image-has-name
Brynanders Mar 26, 2019
2f213a1
Update and rename SVG-image-has-name to SVG-image-has-name.md
Brynanders Mar 26, 2019
e42859f
Update SVG-image-has-name.md
Brynanders Apr 5, 2019
3cc2f55
Update SVG-image-has-name.md
Brynanders Apr 5, 2019
801fd64
Update SVG-image-has-name.md
Brynanders Apr 5, 2019
96a861c
Update SVG-image-has-name.md
Brynanders Apr 5, 2019
7799a15
Typo
ShadowBB Apr 12, 2019
ad33650
Update SVG-image-has-name.md
Brynanders Apr 15, 2019
d956363
Update SVG-image-has-name.md
Brynanders Apr 16, 2019
fa56eea
Update SVG-image-has-name.md
Brynanders Apr 24, 2019
5e9710e
Update SVG-image-has-name.md
Brynanders Apr 24, 2019
668ce46
Update SVG-image-has-name.md
Brynanders Apr 24, 2019
b88c70d
Update SVG-image-has-name.md
Brynanders Apr 29, 2019
aed615b
Add id to frontmatter of rule
May 1, 2019
ec690c0
Update SVG-image-has-name.md
Brynanders May 8, 2019
34f9099
Update SVG-image-has-name.md
Brynanders May 8, 2019
4b65ad8
Update SVG-image-has-name.md
Brynanders May 8, 2019
85248be
Update SVG-image-has-name.md
Brynanders Jun 25, 2019
3a3a311
Update and rename SVG-image-has-name.md to 7d6734.md
Brynanders Jun 25, 2019
b573d82
Update 7d6734.md
Brynanders Jun 25, 2019
04befe9
Update 7d6734.md
Brynanders Jun 25, 2019
e2a0260
Update 7d6734.md
Brynanders Jun 25, 2019
3914d55
Update 7d6734.md
Brynanders Jun 26, 2019
0024ac9
Update 7d6734.md
Brynanders Jul 2, 2019
93e658e
Merge branch 'develop' into Brynanders-patch-4
jeeyyy Jul 3, 2019
c51993e
Update and rename 7d6734.md to SVG-image-has-name-7d6734.md
Brynanders Jul 3, 2019
746afe9
Update SVG-image-has-name-7d6734.md
Brynanders Jul 3, 2019
ba7a786
Update SVG-image-has-name-7d6734.md
Brynanders Jul 3, 2019
01aed67
Update SVG-image-has-name-7d6734.md
Brynanders Jul 3, 2019
5bacf1f
Update SVG-image-has-name-7d6734.md
Brynanders Jul 10, 2019
1b6dd27
Merge branch 'develop' into Brynanders-patch-4
jeeyyy Jul 10, 2019
dacae08
Update and rename SVG-image-has-name-7d6734.md to explicit-SVG-image-…
Brynanders Jul 16, 2019
51515d1
Update explicit-SVG-image-has-name-7d6734.md
Brynanders Jul 16, 2019
5cb80e5
Update explicit-SVG-image-has-name-7d6734.md
Brynanders Jul 22, 2019
56e6d3f
Update explicit-SVG-image-has-name-7d6734.md
Brynanders Sep 11, 2019
4d17154
Update explicit-SVG-image-has-name-7d6734.md
Brynanders Sep 23, 2019
6a14a2e
Typos fixed
Brynanders Sep 25, 2019
fc54e21
Merge branch 'develop' into Brynanders-patch-4
jeeyyy Sep 25, 2019
707bd3b
Merge branch 'develop' into Brynanders-patch-4
WilcoFiers Sep 25, 2019
a355c52
Update explicit-SVG-image-has-name-7d6734.md
Brynanders Oct 2, 2019
53afb1c
Merge branch 'develop' into Brynanders-patch-4
jeeyyy Oct 9, 2019
d5e1837
Merge branch 'develop' into Brynanders-patch-4
jeeyyy Oct 9, 2019
5ee8184
fix failing tests
jeeyyy Oct 9, 2019
41bca24
Update explicit-SVG-image-has-name-7d6734.md
Brynanders Oct 9, 2019
eb6906d
Merge branch 'develop' into Brynanders-patch-4
Jym77 Oct 9, 2019
5ebeb06
Merge branch 'develop' into Brynanders-patch-4
jeeyyy Oct 16, 2019
a466a54
Update explicit-SVG-image-has-name-7d6734.md
Brynanders Oct 16, 2019
596b78f
Update explicit-SVG-image-has-name-7d6734.md
Brynanders Oct 16, 2019
8010531
Merge branch 'develop' into Brynanders-patch-4
Jym77 Oct 16, 2019
6c9ab22
Merge branch 'develop' into Brynanders-patch-4
Jym77 Oct 21, 2019
e94b821
Merge branch 'develop' into Brynanders-patch-4
jeeyyy Oct 24, 2019
fa164a3
Update explicit-SVG-image-has-name-7d6734.md
Brynanders Oct 30, 2019
17176df
Update explicit-SVG-image-has-name-7d6734.md
Brynanders Oct 30, 2019
9a985c1
Merge branch 'develop' into Brynanders-patch-4
jeeyyy Oct 31, 2019
4cca85b
update rule frontmatter
jeeyyy Oct 31, 2019
ab4c29f
Merge branch 'develop' into Brynanders-patch-4
jeeyyy Nov 5, 2019
93009e4
Merge branch 'develop' into Brynanders-patch-4
WilcoFiers Nov 6, 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
21 changes: 12 additions & 9 deletions __tests__/spelling-ignore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,17 @@
- subtags
- testrunner
- color
- focusable
- unfocusable
- tabindex
- whitespace
- namespaces
- focusable
- unfocusable
- tabindex
- whitespace
- namespace
- namespaces
- webpage
- wai-aria-specifications
- autoplay
- autoplays
- presentational

# spell checker checks against strict casing & hence some repeated words here
- Autocomplete
Expand Down Expand Up @@ -115,10 +117,11 @@
- matrix3d

# ARIA Techniques (https://www.w3.org/WAI/WCAG21/Techniques/#aria)
- ARIA1
- ARIA5
- ARIA6
- ARIA7
- ARIA1
- ARIA4
- ARIA5
- ARIA6
- ARIA7
- ARIA8
- ARIA10
- ARIA12
Expand Down
180 changes: 180 additions & 0 deletions _rules/explicit-SVG-image-has-name-7d6734.md
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

### Passed

#### 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">
Copy link

Choose a reason for hiding this comment

The 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:
https://www.w3.org/TR/svg-aam-1.0/#mapping_additional_nd
There are five ways too find the accessible name of an SVG:

  1. aria-labelledby
  2. aria-label
  3. a direct child title element
  4. xlink:title attribute on a link
  5. for text container elements, the text content
    Unless there is something subtle I'm missing about a circle element with role=graphics-symbol, that doesn't count as a text container and none of the other methods apply, so the SVG does not have an accessible name.

Copy link
Collaborator

Choose a reason for hiding this comment

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

The svg element doesn't. But given that it also doesn't have one of the required explicit roles, it is inapplicable for this rule.
The circle element has one of the required explicit roles, thus is applicable; and has an accessible name given by the aria-label, thus it passes the rule.
The example description is about why the circle passes the rule, and says nothing about the svg.

Copy link

Choose a reason for hiding this comment

The 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>
```

#### 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>
Copy link
Collaborator

Choose a reason for hiding this comment

The 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

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.

```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>
```