-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Remove <style> element from the minifyStyles plugin when it is empty #1373
Conversation
@@ -6,7 +6,7 @@ | |||
<stop offset="1" stop-color="#6b5aed" /> | |||
</linearGradient> | |||
</defs> | |||
<path d="M46 24a21.9 21.9" fill="url(#file-name_svg__file-name_svg__original-id)"/> | |||
<path d="M5 24a21.9 21.9 10 1 1 8 18" fill="url(#file-name_svg__file-name_svg__original-id)"/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
M46 24a21.9 21.9
is invalid path data, fixed it.
@@ -0,0 +1,22 @@ | |||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 48 48"> | |||
<defs> | |||
<style>/* test */</style> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At present, the test here fails, and it actually generates:
<style>
</style>
I don't know how to solve it yet.
My two cents here: Wouldn't it make sense to add a plugin that just removes empty Related: #592 (comment) |
@strarsis If there can be better done, I support it. |
This is implemented as part of new mergeStyles plugin. Thanks anyway! |
Continue to improve: #1457 |
Fixed: #1226
In the minifyStyles plugin, if the <style> is empty or the css rule in it is not applied to the current svg node, we should remove the empty <style> element.
A similar process has been done in the inlineStyles plugin.
svgo/plugins/inlineStyles.js
Lines 220 to 223 in 091172a
Origin
Before:
After: