ngx-fast-svg icon indicating copy to clipboard operation
ngx-fast-svg copied to clipboard

fix: support SVGs with metadata

Open hanna-skryl opened this issue 2 years ago • 2 comments
trafficstars

Description

Sometimes, an SVG file can include metadata, like the XML prolog and XML comments that are automatically added by Adobe Illustrator, Sketch, etc. when generating a new SVG.

In such a case, the input is considered invalid, so cache is never created and the image is not loaded.

hanna-skryl avatar Feb 23 '23 23:02 hanna-skryl

The svg needs to get cleaned up.

here we can do the following things:

  • [ ] add information to the docs
  • [ ] add runtime errors (in dev mode, in prod remove the checks from the bundle)
  • [ ] add a cli that cleans up the svg's

Would you be so kind and help with the docs and give me more information about how you discovered the error pls.

BioPhoton avatar Apr 17 '23 22:04 BioPhoton

There are no actual runtime errors. When supplying an SVG file containing extra meta information, what happens is the <fast-svg> element is generated as usual:

<fast-svg name="Name" size="100">
  <svg class="fast-svg" width="100" height="100" viewBox="0 0 100 100">
    <use href="#Name"></use>
  </svg>
</fast-svg>

But the anchor link in the <use> element is invalid, the referred SVG is not in the <div id="svg-cache"></div>, and it's hard to tell at which point it failed.

SVG Optimizer(SVGO) might help with cleaning up the clutter.

hanna-skryl avatar Jun 01 '23 16:06 hanna-skryl