Setting html to `<svg><use xlink:href=...></svg>` produces empty SVG in Chrome
See original GitHub issueCurrent behavior
In Chrome, setting html
parameter to
<svg viewBox="0 0 30 10" xmlns="http://www.w3.org/2000/svg">
<use xlink:href="/test/icons.svg#account"></use>
</svg>
where icons.svg
is
<svg xmlns="http://www.w3.org/2000/svg">
<symbol id="account" viewBox="0 0 24 24">
<path d="M12,4A4,4 0 0,1 16,8A4,4 0 0,1 12,12A4,4 0 0,1 8,8A4,4 0 0,1 12,4M12,14C16.42,14 20,15.79 20,18V20H4V18C4,15.79 7.58,14 12,14Z" />
</symbol>
</svg>
produces empty icon:
Expected behavior
There should be an icon, Firefox works as expected. Most probably the issue is related to https://github.com/sweetalert2/sweetalert2/pull/1930
Live demo
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (8 by maintainers)
Top Results From Across the Web
svg image using xlink:href not working in chrome
EDIT: in my browser, if i visit this page in new tab, the image above displayed as a empty circle. after i click...
Read more >On xlink:href being deprecated in SVG - CSS-Tricks
The attribute we always use for them, xlink:href , is deprecated. Indeed, MDN says:
Read more >Styling SVG <use> Content with CSS - Codrops
To use an element you pass a reference to that element—an ID—inside the use 's xlink:href attribute, and you position that element using...
Read more ><use> - SVG: Scalable Vector Graphics - MDN Web Docs
The element takes nodes from within the SVG document, and duplicates them somewhere else.
Read more >The Best Way to Embed SVG on HTML (2021) - Vecta.io
What's the best way to embed SVGs in HTML 5? How does embedding SVGs using Img tags, Object tags, Inline SVG differs among...
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
Quick update, I tested it on Canary 85.0.x and works fine:
@limonte I spent quite a lot of hours trying to debug it, but I haven’t found anything that can fix it. The only workaround I found is to force chrome to re-render the
<use>
resetting the link after the element has been attached to the destination:I’ll keep doing some more investigation and experiment because I don’t really like this solution…