Skip to content
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

Use of xlink:href in SVG causes rendering problems #31

Open
ahankinson opened this issue Feb 26, 2021 · 0 comments
Open

Use of xlink:href in SVG causes rendering problems #31

ahankinson opened this issue Feb 26, 2021 · 0 comments

Comments

@ahankinson
Copy link

This is similar to #22 but I thought I would add more details since this was actually causing problems with rendering.

Summary: Use of xlink:href in SVG output causes rendering problems with the shadow DOM and IDs.

Minimal demo: An Ellie was created. This demo shows three examples of SVG. The structure of the SVG has common shapes (the note-heads, for example) defined once, and then re-used by reference in the body.

  1. The top uses xlink:href and renders using the Elm view, using the elm-svg-parser to turn a string into Html nodes; as you can see the note heads and other symbols do not appear. The shapes that are defined in-line (the staff lines and note stems) display fine.
  2. The middle is the same setup, except all xlink:href references have been replaced with just href.
  3. The bottom is the control; this is the exact same SVG as in the first example, but set using innerHTML directly in the JavaScript. The references are still xlink:href. This displays correctly.

The best I can figure is that the use of xlink:href does not work with the Shadow DOM or the Elm DOM diffing system; only href works. Outside of the Shadow DOM, it works fine.

The following screenshot shows the output of the DOM; As you can see, in the second and third examples, the Shadow DOM node correctly 'points' to the shared symbol definition and shows it as a child.

svg-shadow-dom

Note that this isn't necessarily an issue with the SVG generator in Elm, and the application that generates the SVG examples here is being updated to support non-namespaced href attributes. But since #22 is still open and gathering use cases and examples, I thought it would be good to add another account of my experiences.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant