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

Use height and width attrs when viewBox is not present #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

e-pavlica
Copy link

Some of the older SVGs that our application uses were exported were exported with a height and width, but no viewBox causing this plugin to break. The "correct" way to fix this problem would be to correct the SVG sources, but that was not something I wanted to pursue.

As a non-perfect fallback for this situation, use the height and width attributes to construct a viewBox string so that compilation can continue.

I didn't add a test for this as I was reluctant to add another fixture to the repo, but can if you prefer.

I also thought about adding a console warning for SVGs missing the viewBox attr but thought that might just be annoying/heavy-handed.

@codecov
Copy link

codecov bot commented May 6, 2020

Codecov Report

Merging #5 into master will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master        #5   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            1         1           
  Lines           29        30    +1     
  Branches         6         7    +1     
=========================================
+ Hits            29        30    +1     
Impacted Files Coverage Δ
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 f00ef0a...3deed80. Read the comment docs.

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.

1 participant