shakyShane / gulp-svg-sprites

Create SVG sprites or compile to <symbols>
MIT License
334 stars 45 forks source link

Issue with Sprite created from SVGs which contain <defs> #113

Closed soumen-basak closed 6 years ago

soumen-basak commented 6 years ago

In the default mode SVGs which contain and are referenced with their ids (example below) are not able to access the in the sprite. This is because they are concatenated in their respective tags. They need to be defined at the top level container tag.

Example sprite (with issue):

<svg>
  <svg>
    <defs>
    </defs>
    ...
  </svg>
  <svg> ...
  </svg>
  ...
</svg>

Example sprite (how it should be):

<svg>
  <defs>
  </defs>
  <svg> ...
  </svg>
  <svg> ...
  </svg>
  ...
</svg>
soumen-basak commented 6 years ago

Upon more examination it seems problem is of duplicate ids being present in the sprite. The original ids are being replaced by 'a', 'b' and so on. With the next svg file being processed this is reset and again the ids start from "a'. This creates duplicate ids in the sprite Seems this is the same problem as #108