scour-project / scour

Scour - An SVG Optimizer / Cleaner
Apache License 2.0
757 stars 61 forks source link

Breaks file by removing clip even when child is referenced by a clone (`<use>`) #296

Open nathanal opened 2 years ago

nathanal commented 2 years ago

Downstream report: https://gitlab.com/inkscape/extensions/-/issues/468

Steps to Replicate

What happened?

What should have happened?

Input

min_example_lost_clone

<?xml version="1.0" encoding="UTF-8"?>
<svg version="1.1" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
 <defs>
  <clipPath id="unusedclip">
  <rect id="the_path" width="100" height="100"/>
  </clipPath>
 </defs>
 <use fill="red" width="100%" height="100%" xlink:href="#the_path"/>
</svg>

Output

<?xml version="1.0" encoding="UTF-8"?>
<svg version="1.1" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
 <use width="100%" height="100%" fill="red" xlink:href="#the_path"/>
</svg>

Version info