Skip to content

[BUG] In 4.0.0-rc.4 (Possibly earlier versions too), stroke="currentColor" case is set incorrectly and breaks windows SVG explorer codecs. #2136

@futuremotiondev

Description

@futuremotiondev

Describe the bug
When a SVG with a stroke="currentColor" or fill="currentColor" is passed through SVGO's default settings, currentColor is replaced with currentcolor. This case transformation doesn't break the SVG entirely - you can open it in Illustrator or Inkscape and it displays fine. But it DOES completely break thumbnail previews in Window Explorer using typical SVG codecs. RESVG is one of them.

Here is a screenshot after processing the "Feather" Icon set:

Broken Rendering

To Reproduce
Steps to reproduce the behavior:

  1. Download the Feather Icon Set.
  2. Unzip the archive.
  3. Run svgo -rf .\Feather\ in the same directory that the Feather folder exists within.
  4. Open the Feather directory and change your explorer view to thumbnails.
  5. You should see that all SVGs are now all rendering as completely black boxes.

Example outputted SVG code:

<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" stroke="currentcolor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" viewBox="0 0 24 24"><path d="M22 12h-4l-3 9L9 3l-3 9H2"/></svg>

What the code should look like:

<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" viewBox="0 0 24 24"><path d="M22 12h-4l-3 9L9 3l-3 9H2"/></svg>

Expected behavior

  1. SVGO to not transform "currentColor" to all lowercase "currentcolor".
  2. After running SVGO, I expect SVGs to render correctly in Windows Explorer using a SVG codec shell extension.

Desktop (please complete the following information):

  • SVGO Version: 4.0.0-rc.4
  • Node.js Version [e.g 16.16.0]: v23.11.0
  • OS: [e.g. iOS]: Windows 10 Pro x64

Additional context
The only fix that needs to be made here is to just not transform "currentColor" to "currentcolor". This has to be unbelievably easy to fix, and it will completely solve the problem.

In the meantime, is there a way that I can disable SVGO from touching the fill/stroke color values?

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueIssue is approved and contributors new to SVGO/OSS are especially encouraged to try to resolve it.help wantedIssue is approved and anyone is encouraged to resolve it in a new pull request.

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions