Skip to content
This repository has been archived by the owner on Oct 9, 2020. It is now read-only.

Apply idPrefix to references in aria-labelledby #68

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

trotzig
Copy link

@trotzig trotzig commented Sep 11, 2017

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
  • <desc> 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:

<title id="__C3oQyi-__shareIconTitle">Share Icon</title>Paper airline silhouette.

(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.


Apart from the above fix, I modified an assertion made in tests to be more robust.

While adding more things to this test, I noticed that the assertion for
idPrefix insertion in xlink:href attributes was lacking the actual
prefix. Adding it should make this bit of code more robust, which is
nice because I'm about to make some changes.
@jsf-clabot
Copy link

jsf-clabot commented Sep 11, 2017

CLA assistant check
All committers have signed the CLA.

@trotzig
Copy link
Author

trotzig commented Sep 11, 2017

Test failures seem unrelated to my changes (they work locally).

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.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants