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

fix(svgo): enable prefixIds by default #8191

Closed
wants to merge 1 commit into from
Closed

fix(svgo): enable prefixIds by default #8191

wants to merge 1 commit into from

Conversation

ilteoood
Copy link

@ilteoood ilteoood commented Oct 8, 2022

Hello guys,
with this PR I would like to activate by default the prefixIds plugin of svgo.

It is useful to avoid any kind of id collision that could happen when are defined different linearGradient for multiple svgs in the same page.

@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Oct 8, 2022
@netlify
Copy link

netlify bot commented Oct 8, 2022

[V2]

Built without sensitive environment variables

Name Link
🔨 Latest commit 20bf243
🔍 Latest deploy log https://app.netlify.com/sites/docusaurus-2/deploys/634196c8d656bd0008a78aba
😎 Deploy Preview https://deploy-preview-8191--docusaurus-2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@github-actions
Copy link

github-actions bot commented Oct 8, 2022

⚡️ Lighthouse report for the deploy preview of this PR

URL Performance Accessibility Best Practices SEO PWA Report
/ 🔴 27 🟢 98 🟢 100 🟢 100 🟠 80 Report
/docs/installation 🟠 73 🟢 100 🟢 100 🟢 100 🟢 90 Report

@slorber
Copy link
Collaborator

slorber commented Oct 12, 2022

Hi

https://github.com/svg/svgo

prefix IDs and classes with the SVG filename or an arbitrary string

Sorry but enabling prefixIds by default is a breaking change that could break the existing CSS selectors of multiple sites. Even if we merge this in a major release, this is likely to annoy many users when upgrading, while it has only be asked by you so far.

Instead of enabling such a thing by default, I'm more likely to accept a PR that allows you to more easily customize the SVGO config: this way you can enable prefixIds yourself and others don't have to change their code.

@slorber slorber closed this Oct 12, 2022
@slorber slorber added the closed: wontfix A fix will bring significant overhead, or is out of scope (for feature requests) label Oct 12, 2022
@ilteoood
Copy link
Author

ilteoood commented Oct 12, 2022

Hi @slorber,
Thank you so much for your review.
The scenario that you are describing sounds a little bit forced.

As svgo changes the ID of each svg file based on usage order, it means that the selector is based on an ephemeral value, which is not the best choise IMO.

What I'm trying to introduce here is a fix for a bug that should not require additional settings: when different svgs files define different gradients, the gradients ID should not overlap as is doing now, mixing color definitions.

Maybe in a major, but IMO this should not be fixed with an external configuration.

@slorber
Copy link
Collaborator

slorber commented Oct 12, 2022

If this is a reasonable default to have in SVGO, then you'd rather convince the SVGO team to enable this by default. If you can, then we'll have this after upgrading and releasing the next SVGO major version.

They probably don't want to enable this by default for the same reason as me.

Some users add hardcoded ids to svgs on purpose, and they don't want those ids to change magically by default, this would be a very confusing default behavior

@ilteoood
Copy link
Author

ilteoood commented Oct 12, 2022

But the hard-coded ids are anyway processed by svgo, which substitute them with "a", "b"...
There is not any predictable ID.

The reason why svgo avoid to enable it by default is that it creates much longer ID than necessary. So, they avoid it until someome needs it.

Btw, fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Signed Facebook CLA closed: wontfix A fix will bring significant overhead, or is out of scope (for feature requests)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants