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

Feature Request: Prevent Original SVG Attributes From Being Removed. #304

Closed
smurrayatwork opened this issue Aug 31, 2018 · 5 comments · Fixed by JetBrains/ring-ui#419
Closed

Comments

@smurrayatwork
Copy link

Do you want to request a feature, report a bug or ask a question?

What is the current behavior?
Currently, when the sprite is generated, it strips off any existing attributes (things like aria-hidden, role, width, height, etc) from the SVG files that are being pulled into the sprite.

What is the expected behavior?
It'd be nice if it were possible to prevent this somehow. If it is already possible, I'd love an example replied to this issue (please and thank you)!

If this is a feature request, what is motivation or use case for changing the behavior?
The motivation here is that I'm trying to use this with React to create an Icon component that pulls SVG files from a directory. These SVG files already have all the attributes they could need. Since they're being stripped away, I have to provide props in my component to add back something that already exists.

Please tell us about your environment:

  • Node.js version: 8.9.4
  • webpack version: 3.x
  • svg-sprite-loader version: 3.8.x
@kisenka
Copy link
Contributor

kisenka commented Sep 19, 2018

Could you please provide an example of your svg file?

@smurrayatwork
Copy link
Author

Sure!

<svg
  aria-hidden="true"
  xmlns="http://www.w3.org/2000/svg"
  version="1.1"
  width="16"
  height="18"
  viewBox="0 0 16 18"
>
  <path
    d="M983.721 1887.28L983.721 1887.28L986.423 1890L986.423 1890L986.423 1890L983.721 1892.72L983.721 1892.72L978.318 1898.17L975.617 1895.45L979.115 1891.92L971.443 1891.92L971.443 1888.0700000000002L979.103 1888.0700000000002L975.617 1884.5500000000002L978.318 1881.8300000000002Z "
    transform="matrix(1,0,0,1,-971,-1881)"
  />
</svg>

@kisenka
Copy link
Contributor

kisenka commented Sep 19, 2018

Okay, I can add needed attributes to white list, could you provide them?
I understand about aria-* and role. But why you need width and height, if you already has viewBox?

@smurrayatwork
Copy link
Author

Agreed on the width and height.

aria-* and role should be good right now.

Thanks!

kisenka added a commit to JetBrains/svg-mixer that referenced this issue Sep 19, 2018
@kisenka
Copy link
Contributor

kisenka commented Sep 19, 2018

@smurrayatwork fixed in svg-sprite-loader@4.1.0

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

Successfully merging a pull request may close this issue.

2 participants