Icon should add an identifier to the <svg> element indicating which icon
See original GitHub issueI was working on implementing react-testing-library in relax, and was following a few of the patterns from @jxnblk 's PR: https://github.com/pricelinelabs/design-system/pull/407/files#diff-76b0baeaa20dde93defea3ea13eb463eR108
One thing that is missing on the svg rendered by the <Icon>
component is a title attribute or some other indicator of what icon it is. This probably also has accessibility concerns, but the primary use case I’m referring to is something like this:
const icon = container.querySelector('svg')
expect(icon).toBeTruthy()
It would be helpful to be able to verify that the icon rendered is the correct one when writing react-testing-library tests.
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
How SVG Fragment Identifiers Work - CSS-Tricks
I just wanna stack the icons on top of each other. If the icons all have the same viewBox and you essentially just...
Read more >Let's Talk SVG Icons: Why and How to Use (and Create) Them
We'll tell you why we love using SVG icons (yes, more than icon fonts!). Plus, learn how to create and style SVG icons...
Read more >onfido/castor-icons - GitHub
When referring to a fragment identifier for an icon to be used, a link is made to icons.svg sprite through the <use> element....
Read more >Introduction – SVG 1.1 (Second Edition) - W3C
An SVG context is a document fragment where all elements within the fragment must be subject to processing by an SVG user agent...
Read more >SVG not showing up with use xlink, only with img src
If you want to use a <use> element and have it work with today's ... <svg> root element and have a fragment identifier...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Yeah, I think for a11y that “decorative” icons should have the
aria-hidden
attribute and icons with meaning can use the<title>
tag – not sure how we’ll want to handle that, but we should do some research to make sure we handle this in a good way