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

inlineStyles plugin doesn't remove all styles elements by default #201

Closed
marcofugaro opened this issue Oct 5, 2018 · 0 comments
Closed

Comments

@marcofugaro
Copy link

🐛 Bug Report

In the 3.0.0 changelog you wrote

Style tag will no longer be automatically removed. SVGO should handle it correctly using "inlineStyles" plugin. If you want to remove them, enable "removeStyleElement" plugin in your SVGO config.

This is wrong, inlineStyles sometimes doesn't remove the style tag, because of the option onlyMatchedOnce. See source codes for details

immagine

To solve this, I have set { inlineStyles: { onlyMatchedOnce: false } }, in the svgoConfig.plugins, but I think this needs to be set inside svgr.

To Reproduce

Use svgr on this svg

<svg xmlns="http://www.w3.org/2000/svg" viewbox="0 0 93 26.31">
  <defs>
    <style>
      .cls-1 {
        fill: #036;
      }
    </style>
  </defs>
  <path
    class="cls-1"
    d="M0,0V26.31H26.31V0ZM6.39,5.64h3.76l-3.76,5.8Zm0,15v-5.8l3.76,5.8Zm15.41-12H14.66v3h6.39v3H14.66v6L9.8,13.16l4.86-7.52H21.8Z"/>
  <path
    class="cls-1"
    data-name="path2 fill"
    d="M34.67,7.48,37,4.68h1.65L36.28,7.44l2.53,4H37.09L35.3,8.62l-.63.75v2H33.19V4.68h1.48Z"/>
</svg>

Expected behavior

Style tag would be removed

Run npx envinfo --system --binaries --npmPackages @svgr/core,@svgr/cli,@svgr/webpack,@svgr/rollup --markdown --clipboard

Paste the results here:

## System:
 - OS: macOS High Sierra 10.13.6
 - CPU: x64 Intel(R) Core(TM) i5-6267U CPU @ 2.90GHz
 - Memory: 153.36 MB / 16.00 GB
 - Shell: 3.2.57 - /bin/bash
## Binaries:
 - Node: 10.11.0 - /usr/local/bin/node
 - Yarn: 1.10.1 - /usr/local/bin/yarn
 - npm: 6.4.1 - /usr/local/bin/npm
gregberge added a commit to smooth-code/h2x that referenced this issue Oct 5, 2018
gregberge added a commit that referenced this issue Oct 5, 2018
gregberge added a commit that referenced this issue Oct 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant