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

Mask colors are changed when using convertColors and currentColor: true #2031

Closed
salvan13 opened this issue Jun 11, 2024 · 0 comments · Fixed by #2032
Closed

Mask colors are changed when using convertColors and currentColor: true #2031

salvan13 opened this issue Jun 11, 2024 · 0 comments · Fixed by #2032
Labels

Comments

@salvan13
Copy link
Contributor

salvan13 commented Jun 11, 2024

Describe the bug
when using the convertColors plugin with the parameter currentColor set to true, if the svg contains mask elements the color attributes (fill/stroke) are changed, this behaivour is unwanted in my case because it breaks the masks depending on the current color.

To Reproduce
Steps to reproduce the behavior:

test.svg:

<svg viewBox="-10 -10 120 120">
  <svg width="100" height="100" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
    <mask id="path-1-inside">
      <path fill-rule="evenodd" clip-rule="evenodd" fill="white"
        d="M9.14286 2H4.85714C4.38376 2.00001 4.00001 2.30381 4 2.67857V20.3214C4.00001 20.6962 4.38376 21 4.85714 21H9.14286C9.61624 21 9.99999 20.6962 10 20.3214V2.67857C9.99999 2.30381 9.61624 2.00001 9.14286 2Z" />
    </mask>
    <path
      d="M9.14286 2L9.1429 0H9.14286V2ZM4.85714 2V0H4.8571L4.85714 2ZM4 2.67857L2 2.6785V2.67857H4ZM4 20.3214H2V20.3215L4 20.3214ZM4.85714 21L4.8571 23H4.85714V21ZM9.14286 21V23H9.1429L9.14286 21ZM10 20.3214L12 20.3215V20.3214H10ZM10 2.67857H12V2.6785L10 2.67857ZM9.14286 0H4.85714V4H9.14286V0ZM4.8571 0C3.73997 2.65837e-05 2.00007 0.78891 2 2.6785L6 2.67865C5.99998 3.21624 5.71952 3.5871 5.49246 3.76685C5.26878 3.94393 5.03752 4 4.85719 4L4.8571 0ZM2 2.67857V20.3214H6V2.67857H2ZM2 20.3215C2.00007 22.2111 3.73997 23 4.8571 23L4.85719 19C5.03752 19 5.26878 19.0561 5.49246 19.2332C5.71952 19.4129 5.99998 19.7838 6 20.3214L2 20.3215ZM4.85714 23H9.14286V19H4.85714V23ZM9.1429 23C10.26 23 11.9999 22.2111 12 20.3215L8 20.3214C8.00002 19.7838 8.28048 19.4129 8.50754 19.2332C8.73122 19.0561 8.96248 19 9.14281 19L9.1429 23ZM12 20.3214V2.67857H8V20.3214H12ZM12 2.6785C11.9999 0.78891 10.26 2.65837e-05 9.1429 0L9.14281 4C8.96248 4 8.73122 3.94393 8.50754 3.76685C8.28048 3.5871 8.00002 3.21624 8 2.67865L12 2.6785Z"
      fill="red" mask="url(#path-1-inside)" />
  </svg>
</svg>

config.js:

module.exports = {
  plugins: [
    {
      name: 'convertColors',
      params: {
        currentColor: true
      }
    }
  ]
}

run:

npx svgo test.svg -o out.svg --config config.js

Expected behavior
in out.svg, path inside mask shouldn't have fill set to currentColor, but should keep white

  • SVGO Version: 3.3.2
  • NodeJs Version: 20.5.1
  • OS: Ubuntu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant