This repository was archived by the owner on Oct 9, 2020. It is now read-only.
Commit 7d5d9af
committed
Apply idPrefix to references in aria-labelledby
To make svgs more accessible to people with screen readers, we can make
use of a few elements and attributes:
- <title> to set a title for the image
- <description> to describe the image
- @aria-labelledby to tell screen readers where the title and
description are located in the tree
Here's some more info on how to best use them:
https://css-tricks.com/accessible-svgs/#article-header-id-6
We're using svg-inline-loader over at brigade.com to make sure every svg
has unique ids, but after adding accessibility markup we noticed that
the references weren't right:
<svg viewBox="0 0 24 24" role="img" aria-labelledby="shareIconTitle shareIconDesc"><title id="__C3oQyi-__shareIconTitle">Share Icon</title><desc id="__C3oQyi-__shareIconDesc">Paper airline silhouette.</desc><path d="M21.184 2.073a.543.543 0 0 1 .806.574l-3.127 16.317a.657.657 0 0 1-.861.494l-4.866-1.825-2.075"></path></svg>
(I've manually removed some stuff from the above svg to make it
shorter).
Notice how the references in aria-labelledby are now referencing missing
ids. To fix this, we can apply the prefix here as well.1 parent e5a07d1 commit 7d5d9af
File tree
3 files changed
+13
-6
lines changed- lib
- tests
- fixtures
3 files changed
+13
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
116 | 116 | | |
117 | 117 | | |
118 | 118 | | |
119 | | - | |
| 119 | + | |
120 | 120 | | |
121 | 121 | | |
122 | 122 | | |
123 | 123 | | |
124 | 124 | | |
125 | | - | |
| 125 | + | |
126 | 126 | | |
127 | 127 | | |
128 | 128 | | |
| |||
155 | 155 | | |
156 | 156 | | |
157 | 157 | | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
158 | 162 | | |
159 | | - | |
160 | 163 | | |
161 | 164 | | |
162 | 165 | | |
| |||
Loading
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
59 | | - | |
60 | | - | |
| 59 | + | |
61 | 60 | | |
62 | 61 | | |
63 | 62 | | |
64 | 63 | | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
65 | 67 | | |
66 | 68 | | |
67 | 69 | | |
| |||
0 commit comments