Skip to content

fix(svg-title): dont render empty title#341

Merged
gregberge merged 2 commits into
gregberge:masterfrom
sudkumar:master
Sep 24, 2019
Merged

fix(svg-title): dont render empty title#341
gregberge merged 2 commits into
gregberge:masterfrom
sudkumar:master

Conversation

@sudkumar

Copy link
Copy Markdown
Contributor

Updates

Summary

Currently when no title is passed and titleProp is set to true, we are
rendering an empty title element which is causing some issues. So we
have added a conditional statement for rendering the title element only
if the title props is not falsy. If we have an existing title, that will
rendered by default. Passing the null values as the title will cause
also cause the title element for not render even if a default title
exists on the svg.

This PR also add support for preserving title attribute which may be present in the svg file.

<svg><title attr="any">Default title</title></svg>

will produce

<svg>
  {title === undefined
    ? <title attr="any">Default title</title>
    : title
      ? <title attr="any">{title}</title> 
      : null}
</svg>

Test plan

Tests have been updated.

Currently when no title is passed and titleProp is set to `true`, we are
rendering an empty title element which is causing some issues. So we
have added a conditional statement for rendering the title element only
if the title props is not falsy. If we have an existing title, that will
rendered by default. Passing the `null` values as the title will cause
also cause the title element for not render even if a default title
exists on the svg

fixes #333
@vercel

vercel Bot commented Sep 19, 2019

Copy link
Copy Markdown

This pull request is automatically deployed with Now.
To access deployments, click Details below or on the icon next to each push.

@codecov

codecov Bot commented Sep 19, 2019

Copy link
Copy Markdown

Codecov Report

Merging #341 into master will increase coverage by 0.03%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #341      +/-   ##
==========================================
+ Coverage   85.03%   85.06%   +0.03%     
==========================================
  Files          30       30              
  Lines         481      482       +1     
  Branches      134      134              
==========================================
+ Hits          409      410       +1     
  Misses         60       60              
  Partials       12       12
Impacted Files Coverage Δ
...ckages/babel-plugin-svg-dynamic-title/src/index.js 100% <100%> (ø) ⬆️

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 4b4bd2c...ab9c416. Read the comment docs.

@gregberge

Copy link
Copy Markdown
Owner

Hello @sudkumar, looks good for me! Thanks!

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.

<title> should be stripped if there is none

3 participants