Skip to content

ClipPath is not scoped to <symbol> #38

Description

@EyMaddis

This is an excellent plugin!

One issue I noticed is the lack of support for clip-path for example as those are referenced within SVG files via id.

Example from MDN

<svg viewBox="0 0 100 100">
  <clipPath id="myClip">
    <!--
      Everything outside the circle will be
      clipped and therefore invisible.
    -->
    <circle cx="40" cy="35" r="35" />
  </clipPath>

  <!-- The original black heart, for reference -->
  <path
    id="heart"
    d="M10,30 A20,20,0,0,1,50,30 A20,20,0,0,1,90,30 Q90,60,50,90 Q10,60,10,30 Z" />

  <!--
    Only the portion of the red heart
    inside the clip circle is visible.
  -->
  <use clip-path="url(#myClip)" href="#heart" fill="red" />
</svg>

Having multiple files that provide <clipPath id="myClip"> means that those lines of code exist multiple times and have naming conflicts as the id stays the same. The spritesheet will now use the first id it encounters instead of the one defined here.

The SVG optimizer svgo (online UI) automatically uses names like #a for any clip path.

Expected Result

Rename all id and references to something unique, like $filename-$id

Currently solveable by manually preparing the file

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions