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

Doesn't update <use /> tag "href" attribute when renumerateIRIElements is true #2671

Open
bodasooqa opened this issue Nov 29, 2023 · 3 comments

Comments

@bodasooqa
Copy link

I have the code in my svg:

<svg ...>
  <path ... />
  <defs>
    <path id="refresh" ... />
    <clipPath id="refresh-clip">
      <use href="#refresh" />
    </clipPath>
  </defs>
  <g clip-path="url(#refresh-clip)">
    ...
  </g>
</svg>

And as a result ids and clip-path are updated: refresh-1, refresh-clip-2, url(#refresh-clip-2), but href attribute of <use /> is still #refresh

@tanem
Copy link
Owner

tanem commented Dec 3, 2023

Thanks for the report. Can you please create a working repro I can look at by forking the basic usage example?

@cocoychris
Copy link

@bodasooqa I just ran into the same issue today as well. Took me a while to find out why some part of my svg is not showing. Good to know I am not the only one who had ran into this issue. Thanks for bringing this up.

@tanem Thanks for maintaining ReactSVG. I think I can provide some information that would help reproduce this issue.

Here is the original svg file I am using:

before.svg
before

After transpiled by ReactSVG, some part of it can not be displayed:

after.svg
after

This is how I use ReactSVG in my code:

import { ReactSVG } from "react-svg"; // Using "react-svg": "^16.1.31",

export default function App() {
  return <ReactSVG src="/before.svg" />; // I didn't set any props. Just use it in the default way
}

The reason I found:

the <path id="clipper"> tag is renamed to <path id="clipper-6">
however the <use href="#clipper"> tag is not updated to <use href="#clipper-6"> .
Please see after.svg:

href_not_updated

The before.svg in plain text for reference:

<svg width="500" height="500"
    viewBox="0 0 500 500"
    xmlns="http://www.w3.org/2000/svg" fill="#6699ff" stroke="#ffffff" stroke-width="5">

    <defs>
        <path id="clipper" d="M350 0 L100 400 L600 500 Z" />
        <clipPath id="ghost_standing:wave_animated">
            <use href="#clipper" x="0">
                <animate
                    attributeName="x" values="0;-210;0"
                    dur="3s" repeatCount="indefinite" />
            </use>
        </clipPath>
        <clipPath
            clipPathUnits="userSpaceOnUse"
            id="ghost_standing:eye_clipper">
            <rect
                width="100"
                height="100"
                x="-50"
                y="-20">
                <animate
                    attributeName="y"
                    values="-20;-20;-20;-20;-20;-20;-20;-20;-20;-20;-20;-20;-20;-20;-20;-20;-20;-20;-20;30;-20;-20;-20;-16;-12;-8;-4;0;4;8;10;50;-40;-20"
                    dur="9s" repeatCount="indefinite" />
            </rect>
        </clipPath>
        <g
            id="ghost_standing:eye_animated"
            clip-path="url(#ghost_standing:eye_clipper)">
            <circle cx="0" cy="0" r="50" fill="white"
                stroke="#cccccc"
                stroke-width="4px" />
            <circle cx="0" cy="0" r="25" fill="black" stroke="none" />
        </g>
    </defs>

    <path
        clip-path="url(#ghost_standing:wave_animated)"
        d="M 457.18552,483.64124 H 42.814481 c 0,0 -21.185211,-465.919231 207.185509,-465.919231 228.37072,0 207.18553,465.919231 207.18553,465.919231 z"
        transform="scale(0.9) translate(25 25)" />
    <use
        x="225"
        y="170"
        href="#ghost_standing:eye_animated"
        width="100%"
        height="100%" />
    <use
        x="335"
        y="170"
        href="#ghost_standing:eye_animated"
        width="100%"
        height="100%" />
</svg>

Hope this would help.

@iscorporacion
Copy link

iscorporacion commented Sep 17, 2024

is there any solutions for this, i have the some problem with this too, i make temporal solution, set renumerateIRIElements to true and working for me

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

4 participants