chore: SVG optimization no longer breaks outline icons #1313
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue
Certain outline icons are being rendered as filled.
Why it's happening
The SVG optimization script currently causes some outline SVGs to be filled. SVGs with
fill="none"
set on thesvg
element has this attribute replaced by anionicon-fill-none
class:ionicons/scripts/build.ts
Line 58 in 116d250
However, the optimized SVG template is then updated to a) remove all non-essential attributes from the
svg
element and b) add theionicon
class:ionicons/scripts/build.ts
Lines 170 to 171 in 116d250
This causes the
ionicon-fill-none
class to be removed from thesvg
element. As a result, outline icons appear filled.How I fixed it
This PR fixes the issue by removing the
.replace
call. During a previous optimization step I ensure that theionicon
class is added to thesvg
element. There are other attributes that need to be removed such aswidth
andheight
. However, these are already being removed inionicons/scripts/build.ts
Line 79 in 116d250
How to test this PR
icon-binocs
. This is icon is being added in feat: add binoculars icons #1258 and reproduces this bug.npm run build
.dist/svg/binoculars-outline.svg
and verify that the icon appears filled.git fetch && git merge origin/icon-svg-optimization
.npm run build
.dist/svg/binoculars-outline.svg
and verify that the icon appears outlined.