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

fix: update SVGO #1016

Merged
merged 2 commits into from
Mar 15, 2021
Merged

fix: update SVGO #1016

merged 2 commits into from
Mar 15, 2021

Conversation

ludofischer
Copy link
Collaborator

  • Update SVGO dependency
  • Refactor plugin to use new SVGO API
  • Refactor test to use new SVGO API
  • Update test since removing xml:space="preserve" was an
    SVGO bug
  • Update documentation since SVGO is now synchronous

)
);

test(
'should optimise inline svg in base64',
processCSS(
"h1{background:url('data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48IURPQ1RZUEUgc3ZnIFBVQkxJQyAiLS8vVzNDLy9EVEQgU1ZHIDEuMS8vRU4iICJodHRwOi8vd3d3LnczLm9yZy9HcmFwaGljcy9TVkcvMS4xL0RURC9zdmcxMS5kdGQiPjxzdmcgdmVyc2lvbj0iMS4xIiBpZD0iTGF5ZXJfMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSI+PGNpcmNsZSBjeD0iNTAiIGN5PSI1MCIgcj0iNDAiIGZpbGw9InllbGxvdyIgLz48IS0tdGVzdCBjb21tZW50LS0+PC9zdmc+')}",
"h1{background:url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjxjaXJjbGUgY3g9IjUwIiBjeT0iNTAiIHI9IjQwIiBmaWxsPSIjZmYwIi8+PC9zdmc+')}"
"h1{background:url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbDpzcGFjZT0icHJlc2VydmUiPjxjaXJjbGUgY3g9IjUwIiBjeT0iNTAiIHI9IjQwIiBmaWxsPSIjZmYwIi8+PC9zdmc+')}"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keeping xml:space="preserve" also causes the base64 output changes. Check:

echo IHhtbDpzcGFjZT0icHJlc2VydmUi | base64 -d -

)
);

test(
'should optimise inline svg (uppercase property)',
processCSS(
'h1{background:URL(\'data:image/svg+xml;utf-8,<?xml version="1.0" encoding="utf-8"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve"><circle cx="50" cy="50" r="40" fill="yellow" /><!--test comment--></svg>\')}',
'h1{background:URL(\'data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg"><circle cx="50" cy="50" r="40" fill="%23ff0"/></svg>\')}'
'h1{background:URL(\'data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve"><circle cx="50" cy="50" r="40" fill="%23ff0"/></svg>\')}'
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the SVGO commit log, removing xml:space="preserve" was a bug svg/svgo@776ec1e

@codecov-io
Copy link

codecov-io commented Mar 14, 2021

Codecov Report

Merging #1016 (4721542) into master (c4a4f69) will decrease coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1016      +/-   ##
==========================================
- Coverage   97.60%   97.59%   -0.01%     
==========================================
  Files         116      116              
  Lines        3589     3579      -10     
  Branches     1059     1059              
==========================================
- Hits         3503     3493      -10     
  Misses         79       79              
  Partials        7        7              
Impacted Files Coverage Δ
packages/postcss-svgo/src/index.js 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c4a4f69...5ebf890. Read the comment docs.

@ludofischer ludofischer force-pushed the update-svgo branch 2 times, most recently from 5ebf890 to feecb04 Compare March 15, 2021 10:17
* Update SVGO dependency
* Refactor plugin to use new SVGO API
* Refactor test to use new SVGO API
* Update test since removing xml:space="preserve" was an
  SVGO bug
* Update documentation since SVGO is now synchronous
Copy link
Member

@alexander-akait alexander-akait left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job, thanks, let's do new rc release after this

@ludofischer ludofischer merged commit 4218332 into master Mar 15, 2021
@ludofischer ludofischer deleted the update-svgo branch March 15, 2021 11:59
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 this pull request may close these issues.

None yet

4 participants