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

CSS Minify Option Breaks inline SVG XML #6822

Closed
jvreeken opened this issue Sep 30, 2016 · 3 comments
Closed

CSS Minify Option Breaks inline SVG XML #6822

jvreeken opened this issue Sep 30, 2016 · 3 comments
Assignees
Labels
Area: Frontend bug report Fixed in 2.2.x The issue has been fixed in 2.2 release line Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development

Comments

@jvreeken
Copy link

jvreeken commented Sep 30, 2016

Preconditions

  1. Magento 2.1.1

Steps to reproduce

  1. In your css, use an svg as an background image
  2. Example:
    background:url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" id="Layer_1" viewBox="0 0 38 40"><style>.st0{fill:none;stroke:%23ffffff;stroke-width:2;stroke-linecap:round;stroke-miterlimit:10;}</style><circle cx="14.7" cy="14.7" r="13.7" class="st0"/><path d="M23.9 24.7L37 39" class="st0"/></svg>') no-repeat left center;
    (Note that Colors with hex values need # to be url encoded to %23 to not break firefox and safari)
  3. Turn on css minify in the backend
  4. deploy static content

Expected result

  1. The svg xml should not be minified / should be minified and url encoded hash symbols for colors to work in all browsers
    background:url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" id="Layer_1" viewBox="0 0 38 40"><style>.st0{fill:none;stroke:%23ffffff;stroke-width:2;stroke-linecap:round;stroke-miterlimit:10;}</style><circle cx="14.7" cy="14.7" r="13.7" class="st0"/><path d="M23.9 24.7L37 39" class="st0"/></svg>') no-repeat left center;

Actual result

  1. The svg xml is not properly parsed and breaks the image and does not display:
    Spaces are removed that should not be removed (marked in bold below)...

background:url('data:image/svg+xml;utf8,<svgxmlns="http://www.w3.org/2000/svg"id="Layer_1"viewBox="**003840**"><style>.st0{fill:none;stroke:%23ffffff;stroke-width:2;stroke-linecap:round;stroke-miterlimit:10;}</style><circlecx="14.7"cy="14.7"r="13.7"class="st0"/><pathd="**M23.924.7L3739**"class="st0"/></svg>') no-repeat left center;

There is a similar example here with other css minify libraries:
yui/yuicompressor#141

I'd like to be able to use inline svgs as background images to reduce http requests.
For now I've just changed them to use svg files in the meantime...

@magento-team
Copy link
Contributor

Internal ticket to track issue progress: MAGETWO-67487

@magento-engcom-team magento-engcom-team added 2.1.x Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development bug report Area: Frontend Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed labels Sep 11, 2017
@magento-engcom-team magento-engcom-team added 2.2.x Fixed in 2.2.x The issue has been fixed in 2.2 release line labels Sep 20, 2017
@magento-engcom-team
Copy link
Contributor

@jvreeken, thank you for your report.
The issue is already fixed in 2.2.0

@Green2Matter
Copy link

Magento 2.4.3-p2 there's exactly same issue: svg (xml) included in custom css file as background is wrongly minified...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Frontend bug report Fixed in 2.2.x The issue has been fixed in 2.2 release line Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development
Projects
None yet
Development

No branches or pull requests

6 participants