Skip to content
This repository has been archived by the owner on May 17, 2019. It is now read-only.

Fix SVG optimization so it doesn't remove symbols for external <use> tags #600

Merged
merged 1 commit into from
Oct 30, 2018

Conversation

lhorie
Copy link
Contributor

@lhorie lhorie commented Oct 30, 2018

Rationale: we want users to be able to take an SVG file such as this:

<svg xmlns="http://www.w3.org/2000/svg">
  <symbol id="mything" viewBox="0 0 24 24">
    <path d="somepath" fill="var(--thing-color)"/>
  </symbol>
</svg>

And use it like this:

const mything = `${assetUrl('../static/mything.svg')}#mything`;

// JSX
<svg width="24" height="24" style={{'--thing-color': '#00f'}}>
  <use xlinkHref={mything} />
</svg>

This PR disables optimizations that prevents this use case from working.

@lhorie lhorie added the bugfix label Oct 30, 2018
Copy link
Contributor

@KevinGrandon KevinGrandon left a comment

Choose a reason for hiding this comment

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

Nice!

@lhorie lhorie merged commit 3cff4d7 into master Oct 30, 2018
@AlexMSmithCA AlexMSmithCA mentioned this pull request Nov 13, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants