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

cleanupIDs breaks this svg #766

Closed
amyspark opened this issue Jul 13, 2017 · 2 comments
Closed

cleanupIDs breaks this svg #766

amyspark opened this issue Jul 13, 2017 · 2 comments

Comments

@amyspark
Copy link

amyspark commented Jul 13, 2017

svgo version: 0.7.2

When I minify the following svg:

<?xml version="1.0" encoding="UTF-8"?>
<svg id="RSSicon" version="1.1" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" xmlns:cc="http://creativecommons.org/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
 <metadata>
  <rdf:RDF>
   <cc:Work rdf:about="">
    <dc:format>image/svg+xml</dc:format>
    <dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/>
    <dc:title/>
   </cc:Work>
  </rdf:RDF>
 </metadata>
 <defs>
  <linearGradient id="RSSa" x1="30.06" x2="225.94" y1="30.06" y2="225.94" gradientUnits="userSpaceOnUse">
   <stop stop-color="#E3702D" offset="0"/>
   <stop stop-color="#EA7D31" offset=".107"/>
   <stop stop-color="#F69537" offset=".35"/>
   <stop stop-color="#FB9E3A" offset=".5"/>
   <stop stop-color="#EA7C31" offset=".702"/>
   <stop stop-color="#DE642B" offset=".887"/>
   <stop stop-color="#D95B29" offset="1"/>
  </linearGradient>
 </defs>
 <g transform="scale(.0625)" stroke-width="16">
  <rect width="256" height="256" rx="55" ry="55" fill="#cc5d15"/>
  <rect x="5" y="5" width="246" height="246" rx="50" ry="50" fill="#f49c52"/>
  <rect x="10" y="10" width="236" height="236" rx="47" ry="47" fill="url(#RSSa)"/>
  <g fill="#fff">
   <circle cx="68" cy="189" r="24"/>
   <path d="M160 213h-34a82 82 0 0 0-82-82V97a116 116 0 0 1 116 116z"/>
   <path d="M184 213A140 140 0 0 0 44 73V38a175 175 0 0 1 175 175z"/>
  </g>
 </g>
</svg>

with the option cleanupIDs enabled, one gets the following file:

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><defs><linearGradient id="RSSa" x1="30.06" x2="225.94" y1="30.06" y2="225.94" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#E3702D"/><stop offset=".107" stop-color="#EA7D31"/><stop offset=".35" stop-color="#F69537"/><stop offset=".5" stop-color="#FB9E3A"/><stop offset=".702" stop-color="#EA7C31"/><stop offset=".887" stop-color="#DE642B"/><stop offset="1" stop-color="#D95B29"/></linearGradient></defs><g stroke-width="16" transform="scale(.0625)"><rect width="256" height="256" fill="#cc5d15" rx="55" ry="55"/><rect width="246" height="246" x="5" y="5" fill="#f49c52" rx="50" ry="50"/><rect width="236" height="236" x="10" y="10" fill="url(#RSSa)" rx="47" ry="47"/><g fill="#fff"><circle cx="68" cy="189" r="24"/><path d="M160 213h-34a82 82 0 0 0-82-82V97a116 116 0 0 1 116 116z"/><path d="M184 213A140 140 0 0 0 44 73V38a175 175 0 0 1 175 175z"/></g></g></svg>

If I view the file standalone, it displays OK.
If I embed it in a web page, the gradient inside the RSS symbol is not shown.

This is the svgo.yml file I am using:

# minify without compressing
plugins:

  # - name
  #
  # or:
  # - name: false
  # - name: true
  #
  # or:
  # - name:
  #     param1: 1
  #     param2: 2

  - removeDoctype: true
  - removeXMLProcInst: true
  - removeComments: true
  - removeMetadata: false
  - removeXMLNS: false
  - removeEditorsNSData: true
  - cleanupAttrs: true
  - minifyStyles: true
  - convertStyleToAttrs: true
  # BREAKS CC DO NOT ENABLE
  - cleanupIDs: true
  - removeRasterImages: true
  - removeUselessDefs: true
  - cleanupNumericValues: true
  - cleanupListOfValues: true
  - convertColors: true
  - removeUnknownsAndDefaults: true
  - removeNonInheritableGroupAttrs: true
  - removeUselessStrokeAndFill: true
  - removeViewBox: true
  - cleanupEnableBackground: true
  - removeHiddenElems: true
  - removeEmptyText: true
  - convertShapeToPath: true
  - moveElemsAttrsToGroup: true
  - moveGroupAttrsToElems: true
  - collapseGroups: true
  - convertPathData: true
  - convertTransform: true
  - removeEmptyAttrs: true
  - removeEmptyContainers: true
  - mergePaths: true
  - removeUnusedNS: true
  # ERROR WITH GITHUB
  - transformsWithOnePath: false
  - sortAttrs: true
  - removeTitle: true
  - removeDesc: true
  - removeDimensions: true
  - removeAttrs: true
  - removeElementsByAttr: true
  - addClassesToSVGElement: false
  - removeStyleElement: true
  - removeScriptElement: true
  - addAttributesToSVGElement: false
@amyspark
Copy link
Author

It's not svgo, it's a bad interaction between two SVGs. See #674.

@JoshyPHP
Copy link
Contributor

For future reference, this was most likely a naming collision, e.g. another element using id="RSSa".

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

No branches or pull requests

2 participants