-
-
Notifications
You must be signed in to change notification settings - Fork 225
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
Empty attributes in inline SVG get stripped #576
Comments
Fixed! Are you sure about the empty attribute syntax? I think it says that you should just write the name (without the |
@tdewolff oh wow, that was fast. Thank you very much. Yes, I am sure. My brain mixed up old HTML information with the formerly linked empty-attribute-syntax. However, the information is still valid for current HTML versions, I edited my original posting. TL;DR: boolean attributes may legally take a single value: the name of the attribute itself (e.g., |
@tdewolff just writing the name is still the wrong way it seems. Firefox for example does not render SVGs with |
Thanks, should be fixed now. XML and thus SVG must explicitly have an empty value. |
Hello,
empty attributes in inline SVG images are getting stripped (unexpected) while being kept (as expected) in other HTML tags. Example code:
results in (line breaks added for better readability)
As one can see, empty attributes like
x-ignore x-cloak x-foo=""
are getting stripped from the inline<svg>
image. I guess this happens as they are handled by the SVG minifier instead of the HTML one (which makes sense but an option to keep empty attributes on SVG would be nice).I got this problem while using Minify as included in the static site generator Hugo, the issue is reproducible with the minify online demo running v2.12.5.
If somebody else ran into this problem: A workaround is to use the name of the attribute itself as value for boolean attributes
So e.g.
x-ignore="x-ignore"
in my example code. The attributes will be preserved then. I ran into this problem as I use Apline.js'sx-ignore
directive for the SVG tags to optimize Alpine.js-performance.The text was updated successfully, but these errors were encountered: