-
Notifications
You must be signed in to change notification settings - Fork 437
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mermaid duplicating ids #1440
Comments
Good find. I could not reproduce this on GH nor Mermaid's Live Editor. Both of them use a unique integer for each Mermaid element, we should most likely do the same. :) |
@josevalim GH loads graphs in an iframe, while in Mermaid's Live Editor I don't think we can enter multiple graphs at once to reproduce this? One thing is that we cache the SVG content by mermaid content, however that's not really the problem here, because in the example all graphs are different. If you look at the error log, there are ids like If you go to Mermaid flowchart docs and look for |
@williamthome can you please report this bug in Mermaid and see what do they say? @jonatanklosko worst case scenario we will need to wrap them in iframes too? |
@josevalim I think we could traverse the elements and replace the ids to ensure they are unique. |
@josevalim Yes, I will do this tonight. |
I can confirm that @williamthome is correct and mermaid currently creates SVG markers with duplicate ids when there are multiple diagrams on the same html page. The fix was to prefix the id of I will follow up with the mermaid team to see when this will get merged (I have only recently started with mermaid and am not a contributor). |
If you decide to roll your own unique id you will need to take care to update |
@dwhelan thanks for the insights! Prefixing all ids sounds like the way to go, hopefully they accept it upstream. And to handle caching we could set the id to something like |
@dwhelan Is this your fix? Did you create the PR? mermaid-js/mermaid@develop...dwhelan:mermaid:fix/1871_lineColor_spill |
Closing in favor of mermaid-js/mermaid#4825 |
@williamthome perfect, thanks for checking! |
Environment
git rev-parse HEAD
if running with mix): 3980e48ec9dc262655fac8bbbafdd2a3b036dbfdCurrent behavior
I just cloned the DockYard-Academy/beta_curriculum and I'm receiving a bunch of errors of duplicated ids. See the gif below (sorry for the intro delay, but it took some time to raise the errors):
The error occurs just by entering the on the page Week 1: Core Syntax | 1. Course Tools or clicking on some evaluate block.
Investigating, I found the error comes from mermaid.
The referred page contains these MD blocks:
Use this command in the browser console to find the dups:
Mermaid defines the "flowchart-" ids here and "L-" ids here.
Some screenshots:
Expected behavior
No errors in the browser console.
The text was updated successfully, but these errors were encountered: