question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Generated SVG has static IDs which cause issues when there are two SVGs

See original GitHub issue

Describe the bug In the attached (zipped) html, there are two SVGs generated by mermaid. Loaded in a browser they will render with arrowheads. However, if the first SVG style has ‘display:none’ then not only does it disappear (as expected), but also the arrow heads in the second SVG. The reason is that they are referenced as #arrowhead and so the browser finds them in the first SVG, which is not displayed, hence they are not displayed.

svgs.zip

Expected behavior Create unique IDs. E.g. use the id passed to render as prefix. (Note: there is another generic solution which is to wrap each SVG in an iframe via srcdoc. However, then styling in the outer doc can’t be applied to the svg elements which for my context of static HTML files is not good)

Screenshots When both are visible: image

When first one is not displayed: image

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
dwhelancommented, Sep 30, 2022

Yes @williamthome, I believe this is root cause of what you saw with https://github.com/livebook-dev/livebook/issues/1440. I do not have an ETA on getting that merged but will respond here when it is done. Is it urgent for you?

0reactions
bjarkihcommented, Oct 7, 2022

This is pretty urgent for me - would love to see your fix get merged in as soon as feasible @dwhelan 🙏🏻

Read more comments on GitHub >

github_iconTop Results From Across the Web

Multiple svg with same IDs - Stack Overflow
Both methods were developed so the same SVG can be injected multiple times into a HTML document without creating an ID conflict.
Read more >
If You're Inlining SVG Icons, How Do You Deal With Unique ...
One of those reasons might be because you just want an ID on the icon to uniquely identify it for JavaScript or styling...
Read more >
The Best Way to Embed SVG on HTML (2021) - Vecta.io
Because they are encapsulated, they can contain IDs and classes that are duplicated in other image files, without causing any display problems.
Read more >
Introduction – SVG 1.1 (Second Edition) - W3C
SVG is a language for describing two-dimensional graphics in XML [XML10]. ... It is recommended that SVG files stored on Macintosh HFS file...
Read more >
Fix duplicate SVG ID collision in React | by Anton Ball - Medium
The solution is going to depend on your setup. If you're using SVGO there's a lively discussion on an issue raised that suggest...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found