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

Icons with masks are displayed as if without masks #288

Closed
0pt1m1z3r opened this issue Jun 26, 2018 · 12 comments
Closed

Icons with masks are displayed as if without masks #288

0pt1m1z3r opened this issue Jun 26, 2018 · 12 comments

Comments

@0pt1m1z3r
Copy link

0pt1m1z3r commented Jun 26, 2018

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

What is the current behavior?
Icons with masks are displayed as if without masks
2018-06-26 11 26 51

What is the expected behavior?
Masks must be applied correctly

If the current behavior is a bug, please provide the steps to reproduce, at least part of webpack config with loader configuration and piece of your code.
The best way is to create repo with minimal setup to demonstrate a problem (package.json, webpack config and your code).
It you don't want to create a repository - create a gist with multiple files
https://github.com/0pt1m1z3r/svg-test

If this is a feature request, what is motivation or use case for changing the behavior?

Please tell us about your environment:

  • Node.js version: 8.11.3
  • webpack version: 3.12.0
  • svg-sprite-loader version: master branch (because 3.9.0 is not published)
  • OS type & version: macOS 10.13.5 (17F77)

Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, gitter, etc)
In Chrome 67.0.3396.87:
Source svg icon - correct
Svg icon from sprite - correct
Svg icon from sprite in img tag - correct
Svg icon from sprite in use tag - incorrect
In Firefox 60.0.2:
Source svg icon - correct
Svg icon from sprite - incorrect
Svg icon from sprite in img tag - incorrect
Svg icon from sprite in use tag - incorrect

@porfirioribeiro
Copy link

Was about to report the same problem with filters and gradients.

I guess it's because how svg links those def's using #links
Dunno if there is a way to generate the sprite in a way to make the links correct 😞

@0pt1m1z3r
Copy link
Author

@kisenka can you help?

@kisenka
Copy link
Contributor

kisenka commented Aug 4, 2018

@0pt1m1z3r could you please create repo with minimal setup to demonstrate a problem (package.json, webpack config, SVG image and piece of your code). If you don't want to create a repository - you can create a gist with multiple files.

@0pt1m1z3r
Copy link
Author

@0pt1m1z3r
Copy link
Author

@kisenka can you help?

@kisenka
Copy link
Contributor

kisenka commented Aug 17, 2018

I it'a browsers issue, how they render external SVGs in sprite stack. If you guys tell me how to transform an SVG to get it work - I'll be glad to update sprite generator. The only thing I can suggest is to use SVG sprite inlined directly on the page. I've created a PR 0pt1m1z3r/svg-test#1 to demonstrate how it can be done.

@kisenka
Copy link
Contributor

kisenka commented Aug 17, 2018

@0pt1m1z3r BTW if refer to SVGs from CSS all works fine :)

@0pt1m1z3r
Copy link
Author

Thank you. I will continue to investigate this problem

@kisenka
Copy link
Contributor

kisenka commented Sep 19, 2018

@0pt1m1z3r can I close this one?

@0pt1m1z3r
Copy link
Author

@kisenka Yes, you can. I use the solution via css.

@kisenka kisenka closed this as completed Sep 19, 2018
@invernizzi
Copy link

invernizzi commented Oct 9, 2018

Hi there, just chiming in to help future readers of this bug.

If you need to load a sprite via a <use> tag in Firefox and you see weird behavior with <mask>s and clip paths like the one shown in the first comment, it's because of this Firefox "oddity".
https://bugzilla.mozilla.org/show_bug.cgi?id=353575

You can fix that by running something like this after loading the sprite:

   document
        .querySelectorAll('#__SVG_SPRITE_NODE__ symbol mask')
        .forEach(element =>
          document.querySelector('#__SVG_SPRITE_NODE__').appendChild(element)

This workarounds moves <mask> elements from inside the symbol to the root of the sprite node, allowing Firefox to load them. Watch out for potential id conflicts (ideally, there shouldn't be, as this loader prefixes ids automatically).

@kisenka
Copy link
Contributor

kisenka commented Jan 24, 2020

Fixed in svg-sprite-loader@4.2.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

No branches or pull requests

4 participants