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

Replace xlink:href by href? #1158

Closed
pfefferniels opened this issue Oct 15, 2019 · 11 comments
Closed

Replace xlink:href by href? #1158

pfefferniels opened this issue Oct 15, 2019 · 11 comments
Labels

Comments

@pfefferniels
Copy link

The SVG that verovio generates seems to make frequent use xlink:href attributes in <use> elements. xlink:href is deprecated in SVG2 and I just ran into a strange bug where SVG.js failed to calculate bounding boxes because of that. Could it be replaced by just href?

@lpugin
Copy link
Contributor

lpugin commented Oct 15, 2019

There is no plan to move to SVG2 in the near future. What is SVG.js?

@lpugin
Copy link
Contributor

lpugin commented Oct 15, 2019

As far as I remember the xlink:href was chosen because some viewers would not work otherwise. I think it is (or was) the case for Safari.

@lpugin lpugin added the wontfix label Oct 16, 2019
@lpugin lpugin closed this as completed Oct 16, 2019
@pfefferniels
Copy link
Author

pfefferniels commented Oct 16, 2019

I see. This page was warning that some browser won't support it anymore in some future point.
SVG.js It's a library for manipulating SVG. I use it server-side in combination with svgdom. It only supports href, not xlink:href ...

@lpugin
Copy link
Contributor

lpugin commented Oct 16, 2019

Since you use it server-side the best for now is simply to pipe the output through a simple XSLT that changes the attribute to href. Would this work for you?

I think it will be a long way until most browsers will support SVG 2.0, and until them it will be wiser to stick with the current version.

@lpugin
Copy link
Contributor

lpugin commented Oct 16, 2019

As you can see here, href still has lower support than xlink:href:
https://caniuse.com/#search=svg%20xlink%3Ahref
https://caniuse.com/#search=svg%20href

@pfefferniels
Copy link
Author

Since you use it server-side the best for now is simply to pipe the output through a simple XSLT that changes the attribute to href. Would this work for you?

I think it will be a long way until most browsers will support SVG 2.0, and until them it will be wiser to stick with the current version.

Yes, that's what I am going to do. Thanks for the information :)

@rettinghaus
Copy link
Contributor

No need for replacement yet. The latest W3C Candidate Recommendation says:

A conforming SVG generator must generate ‘href’ attributes without a namespace. However, it may also generate ‘href’ attributes in the XLink namespace to provide backwards compatibility.

If we simply double the information we should achieve a higher compatibility.

@kepper
Copy link
Contributor

kepper commented Oct 16, 2019

…and we would increase filesizes considerably. I'm frequently running into issues with that, so I'm not in favor. Could that be an option in Verovio?

@rettinghaus
Copy link
Contributor

Just tested it. It increases file sizes by about 2% to 3%.
@kepper compared to the output older versions of Verovio created that's still small. ;-)

@rettinghaus
Copy link
Contributor

@kepper Tried to update Beethovens Werkstatt?

@kepper
Copy link
Contributor

kepper commented Oct 16, 2019

No time to look back at old versions – neither of Verovio nor our own tools. Right now I face files with 750+ measures / 8 staves, and huge amounts of additional (analytical) markup. This mostly affects RAM, but the plain XML easily exceeds 10MB. But that's a different story, and I'm not complaining. I just don't think that duplicating information is particularly clever…

ahankinson added a commit that referenced this issue Feb 26, 2021
After some extensive testing it seems that some browsers, in some cases, will not display SVG if the `href` attribute is prefixed with `xlink`, a change that was introduced with SVG 2.0. This is not yet a recognized specification, but the changes in browsers are being enacted nevertheless.

On the other hand, some strict SVG 1.1 clients will not render the SVG correctly if it *doesn't* include the `xlink:` prefix. In my testing this included Inkscape.

Given that the most likely target for Verovio output is browsers, but still wishing to retain backwards compatibility, this PR changes the default behaviour from producing `xlink:href` to simply `href`. Clients that need the full attribute name can set `--svg-include-xlink` which will insert the xlink prefix on the href attributes.

References previous discussions on this topic: #1158, #332
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants