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

Regression in 3.0.4: incorrectly removes reusable elements, but leaves references to it #1851

Closed
cyberalien opened this issue Nov 26, 2023 · 9 comments · Fixed by #1852 or #1879
Closed
Labels

Comments

@cyberalien
Copy link
Contributor

Describe the bug
Combination of the following 3 plugins since version 3.0.4 incorrectly removes reusable element, resulting in broken icon:

'removeHiddenElems',
'convertPathData',
'reusePaths',

To Reproduce
Attempt to optimise the following icon using 3 plugins listed above:

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 128 128">
	<path fill="#BD202E" d="M15.852 62.452Z"/>
	<path fill="#BD202E" d="M15.852 62.452Z" opacity=".35"/>
</svg>

Expected behavior
Expected icon that works: either empty (since paths are useless) or at least not broken.

Actual behavior
Actual result:

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 128 128">
        <use href="#reuse-0"/>
        <use opacity=".35" href="#reuse-0"/>
    </svg>

Element with id reuse-0 is missing.

Desktop (please complete the following information):

  • SVGO Version: 3.0.4
  • NodeJs Version: 20.5.0
  • OS: macOS 14.1.1

Additional context
In version 3.0.3 same code results in:

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 128 128">
        <defs>
                <path fill="#BD202E" d="M15.852 62.452Z" id="reuse-0"/>
        </defs>
        <use href="#reuse-0"/>
        <use opacity=".35" href="#reuse-0"/>
    </svg>

Plugin removeHiddenElems fails in 3.0.3, but at least icon is not broken.

@SethFalco
Copy link
Member

Thanks for reporting the issue!

I've fixed this in #1852. Feedback welcome if you can spot any problems or edge cases I haven't considered.

With the proposed changes, we'll create an empty SVG in your scenario:

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 128 128">
	<path fill="#BD202E" d="M15.852 62.452Z"/>
	<path fill="#BD202E" d="M15.852 62.452Z" opacity=".35"/>
</svg>

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 128 128"/>

@cyberalien
Copy link
Contributor Author

Something else is broken. Ran 3.0.5 with original file, which this reduced test case is from, it failed with exactly the same issue.

Original full SVG:

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 128 128">
	<path fill="url(#a)" d="M20.825 40.232c-.768.453-2.045 1.735-3.563 3.596l1.396 2.639c.983-1.402 1.98-2.667 2.985-3.746l.116-.125-.116.125c-.326.357-1.314 1.512-2.803 3.8 1.435-.071 3.638-.365 5.436-.671.538-3-.523-4.37-.523-4.37s-1.348-2.18-2.928-1.248Z"/>
	<path fill="#BD202E" d="M16.127 62.401c-.179.031-.36.065-.55.096 0 0-.002 0-.002.003l.283-.042c.087-.02.178-.037.269-.057Z"/>
	<path fill="#BD202E" d="M16.127 62.401c-.179.031-.36.065-.55.096 0 0-.002 0-.002.003l.283-.042c.087-.02.178-.037.269-.057Z" opacity=".35"/>
	<path fill="#BD202E" d="M16.594 60.093s0 .003 0 0c-.003 0-.003 0-.003.003a.954.954 0 0 0 .088-.014 3.45 3.45 0 0 0 .348-.065l-.433.076Z"/>
	<path fill="#BD202E" d="M16.594 60.093s0 .003 0 0c-.003 0-.003 0-.003.003a.954.954 0 0 0 .088-.014 3.45 3.45 0 0 0 .348-.065l-.433.076Z" opacity=".35"/>
	<path fill="url(#b)" d="M14.535 53.289a84.41 84.41 0 0 1 1.289-2.325c.45-.787.909-1.546 1.37-2.282.026-.043.057-.088.082-.13.456-.723.918-1.42 1.38-2.082l-1.397-2.64c-.104.128-.21.258-.317.394a60.057 60.057 0 0 0-1.251 1.617c-.485.646-.98 1.337-1.487 2.062a82.256 82.256 0 0 0-2.625 3.998l-.043.074 1.821 3.596a81.55 81.55 0 0 1 1.178-2.282Z"/>
	<path fill="url(#c)" d="M6.244 73.541c-.24.66-.484 1.337-.725 2.025-.003.008-.006.02-.011.028-.034.097-.071.196-.102.292-.164.464-.306.883-.632 1.832.535.244.966.89 1.374 1.62a2.917 2.917 0 0 0-.952-2.016c2.642.118 4.919-.55 6.097-2.481.105-.173.201-.351.289-.546-.535.68-1.2.965-2.45.897-.002 0-.005.003-.008.003.003 0 .005-.003.008-.003 1.841-.824 2.761-1.614 3.58-2.922.192-.312.382-.649.575-1.025-1.609 1.65-3.47 2.12-5.432 1.764l-1.472.161c-.048.125-.09.247-.139.371Z"/>
	<path fill="url(#d)" d="M6.932 70.248c.317-.821.646-1.654.98-2.492.323-.804.651-1.614.991-2.424.34-.81.685-1.628 1.036-2.444.357-.83.725-1.656 1.102-2.48.37-.816.745-1.626 1.127-2.424.136-.29.277-.578.416-.864.24-.495.485-.988.73-1.475.015-.026.026-.054.04-.08l-1.82-3.596c-.029.048-.06.1-.09.145a79.726 79.726 0 0 0-3.486 6.284c-.066.13-.128.262-.193.393a55.064 55.064 0 0 0-1.08 2.364 46.74 46.74 0 0 0-1.481 3.939c-.127.405-.246.813-.365 1.218a37.936 37.936 0 0 0-.699 2.849l1.83 3.61c.24-.646.49-1.303.744-1.965.077-.19.144-.377.218-.558Z"/>
	<path fill="url(#e)" d="M4.12 69.282a28.027 28.027 0 0 0-.476 3.45l-.008.118c-.572-.914-2.098-1.806-2.096-1.798 1.096 1.586 1.926 3.16 2.048 4.706-.586.12-1.388-.053-2.314-.393.966.89 1.69 1.133 1.977 1.2-.89.057-1.812.666-2.744 1.368 1.362-.555 2.463-.776 3.25-.597-1.25 3.54-2.503 7.447-3.757 11.599.385-.114.614-.374.742-.722.224-.75 1.705-5.684 4.03-12.16l.2-.555c.018-.054.037-.105.057-.153.244-.68.501-1.373.762-2.081.06-.162.119-.323.181-.484l.003-.009-1.832-3.61-.023.121Z"/>
	<path fill="url(#f)" d="M13.638 55.866c-.054.107-.105.215-.159.322-.159.326-.317.657-.481.997a110.056 110.056 0 0 0-.802 1.713 156.01 156.01 0 0 0-.827 1.835c-.342.773-.696 1.58-1.05 2.419-.337.798-.685 1.622-1.03 2.477a204.444 204.444 0 0 0-1.921 4.882l-.042.116c-.306.807-.615 1.637-.923 2.487-.006.02-.015.036-.02.06l1.472-.162c-.028-.006-.06-.009-.088-.014 1.759-.219 4.1-1.535 5.61-3.158.697-.747 1.328-1.63 1.912-2.665.433-.767.843-1.622 1.234-2.565.34-.824.666-1.719.98-2.684-.405.212-.867.37-1.376.478a7.674 7.674 0 0 1-.558.096s.003 0 .003-.002c1.642-.632 2.676-1.85 3.426-3.342-.43.294-1.133.68-1.974.864a6.406 6.406 0 0 1-.436.079h.006a6.61 6.61 0 0 0 1.467-.821c.09-.068.178-.136.258-.21.127-.11.246-.226.365-.345a5.551 5.551 0 0 0 .674-.872c.042-.071.087-.14.127-.213.057-.105.108-.21.159-.308a16.625 16.625 0 0 0 .75-1.736 6.68 6.68 0 0 0 .062-.181c.06-.173.105-.326.142-.462a4.19 4.19 0 0 0 .108-.482 1.888 1.888 0 0 1-.193.13c-.496.298-1.345.564-2.03.692l1.35-.147-1.35.147c-.009.003-.02.003-.031.005-.071.012-.136.023-.207.032l.034-.017-4.624.506a.14.14 0 0 1-.017.049Z"/>
	<path fill="url(#g)" d="M18.842 46.52a69.722 69.722 0 0 0-1.421 2.289 94.468 94.468 0 0 0-1.328 2.32 107.547 107.547 0 0 0-2.433 4.688l4.625-.507c1.347-.62 1.948-1.178 2.531-1.99.153-.224.312-.456.465-.7a28.68 28.68 0 0 0 1.356-2.37c.402-.784.756-1.56 1.028-2.262.173-.445.311-.858.408-1.224.084-.32.15-.625.2-.917-1.792.309-3.998.603-5.43.674Z"/>
	<path fill="#BD202E" d="M15.852 62.452Z"/>
	<path fill="#BD202E" d="M15.852 62.452Z" opacity=".35"/>
	<path fill="url(#h)" d="M15.852 62.452Z"/>
	<path fill="#BD202E" d="M16.591 60.096a.922.922 0 0 0 .088-.014c-.028.003-.057.011-.088.014Z"/>
	<path fill="#BD202E" d="M16.591 60.096a.922.922 0 0 0 .088-.014c-.028.003-.057.011-.088.014Z" opacity=".35"/>
	<path fill="url(#i)" d="M16.591 60.096a.922.922 0 0 0 .088-.014c-.028.003-.057.011-.088.014Z"/>
	<path fill="#BD202E" d="M16.591 60.096c.003 0 .003-.003 0 0 .003-.003.003 0 0 0Z"/>
	<path fill="#BD202E" d="M16.591 60.096c.003 0 .003-.003 0 0 .003-.003.003 0 0 0Z" opacity=".35"/>
	<path fill="url(#j)" d="M16.591 60.096c.003 0 .003-.003 0 0 .003-.003.003 0 0 0Z"/>
	<path fill="#cb2533" d="M82.837 74.447a19.717 19.717 0 0 1-1.522-.39c-.393-.152-1.743-.844-1.901-.974a11.576 11.576 0 0 0-.625-.483c-.382-.285-1.202-1.105-1.487-1.488a16.216 16.216 0 0 0-.296-.387c-.04-.05-.11-.133-.152-.186-.09-.11-.85-1.395-.85-1.437 0-.015-.08-.204-.176-.42-.097-.216-.234-.56-.305-.764a11.17 11.17 0 0 0-.193-.52c-.079-.182-.293-1.193-.37-1.745-.083-.584-.08-2.187.003-2.712.22-1.38.395-1.971.9-3.05.077-.166.14-.341.14-.39 0-.048.034-.088.075-.088.04 0 .074-.043.074-.096 0-.053.206-.408.459-.79.409-.62 1.34-1.65 1.955-2.161.636-.529 1.893-1.217 2.644-1.448.221-.068.485-.153.587-.188.378-.13 1.103-.225 2.043-.267 1.212-.054 2.483.104 3.38.42.67.237 1.284.52 1.325.612.013.03.057.056.096.056.157 0 1 .639 1.507 1.14.586.582.97 1.09 1.273 1.69.19.376.192.395.06.486a8.883 8.883 0 0 0-.216.154 3.755 3.755 0 0 1-.272.17c-.106.06-.347.206-.536.323-.383.237-.53.22-.642-.077-.315-.828-1.76-2.188-2.744-2.581-1.083-.434-1.74-.563-2.855-.562-1.18.001-1.94.146-2.884.551-.323.138-1.011.55-1.155.69-.055.053-.122.096-.15.096-.078 0-.904.815-1.268 1.251-.393.473-1.077 1.688-1.238 2.203a7.099 7.099 0 0 1-.182.52c-.316.718-.501 2.46-.386 3.62.078.795.243 1.627.387 1.95.036.082.088.233.115.335.12.45.819 1.754 1.186 2.21.365.454 1.033 1.156 1.337 1.405.347.285 1.474.99 1.584.99.027 0 .136.046.241.101.106.055.49.18.855.278.557.15.822.177 1.665.17 1.41-.014 2.306-.257 3.491-.95.777-.455 1.85-1.504 2.229-2.18.142-.254.293-.463.334-.464.157-.002 1.597.781 1.597.87 0 .103-.433.929-.518.987a.746.746 0 0 0-.14.2c-.177.336-.99 1.131-1.756 1.717-.407.31-1.483.857-2.229 1.132-.99.365-1.592.462-2.97.483-.736.012-1.422.006-1.524-.013Zm-59.276-.104c0-.042.032-.134.072-.205.04-.07.142-.296.227-.5.085-.204.184-.438.22-.52.036-.082.27-.633.52-1.226.25-.592.484-1.143.521-1.225.037-.082.154-.366.26-.632.106-.265.223-.55.26-.631l.224-.52c.087-.204.206-.477.264-.606.059-.128.106-.255.106-.282 0-.042.143-.385.373-.895.036-.081.153-.366.259-.631.106-.266.223-.55.26-.632.037-.081.154-.365.26-.63.105-.266.222-.55.259-.632.037-.082.137-.316.224-.52a131.676 131.676 0 0 0 .63-1.486c.189-.45.373-.884.41-.965.036-.082.203-.483.37-.892.168-.408.335-.81.372-.891.036-.082.183-.433.326-.78.8-1.946.984-2.386 1.162-2.786.036-.081.153-.366.26-.631.106-.266.258-.625.337-.799l.145-.315h1.614l.166.39c.206.485.433 1.011.52 1.207.253.567.372.852.372.891 0 .042.142.378.414.977.058.129.106.256.106.283 0 .042.115.318.371.894.253.568.372.852.372.892 0 .024.069.202.154.394.084.191.203.465.264.608.062.143.141.327.178.409.036.082.152.366.258.631.106.266.222.55.259.632.036.081.27.633.52 1.225.251.593.486 1.144.522 1.226.037.082.12.282.187.446.683 1.677.955 2.337 1.039 2.525.055.123.237.557.406.966a63.101 63.101 0 0 0 .595 1.411c.086.204.187.439.224.52.037.082.153.366.259.632.106.265.223.55.26.63.36.798.817 1.923.817 2.01 0 .09-.182.108-1.072.108-1.047 0-1.073-.004-1.123-.167-.046-.15-.218-.569-.405-.984a26.47 26.47 0 0 1-.261-.632 33.296 33.296 0 0 0-.483-1.151 28.372 28.372 0 0 1-.259-.632c-.105-.265-.222-.55-.259-.63-.225-.501-.372-.853-.372-.892 0-.025-.062-.186-.138-.357a54.03 54.03 0 0 1-.24-.553l-.104-.242H28.26l-.15.353c-.082.194-.24.587-.353.873-.111.286-.265.66-.342.832a2.42 2.42 0 0 0-.139.356c0 .04-.146.392-.372.892-.037.082-.153.366-.26.631-.105.266-.223.55-.26.632-.039.081-.19.449-.338.817l-.307.761c-.049.118-2.177.135-2.177.018Zm13-7.803c0-.07-.11-.338-.414-1.01a1.449 1.449 0 0 1-.107-.286c0-.028-.048-.157-.108-.286a44.727 44.727 0 0 1-.52-1.274 57.218 57.218 0 0 0-.483-1.188 36.26 36.26 0 0 1-.41-1.04 47.07 47.07 0 0 0-.408-1.04 40.717 40.717 0 0 1-.177-.408 67.71 67.71 0 0 0-.265-.61 2.545 2.545 0 0 1-.155-.408.924.924 0 0 0-.096-.245 8.45 8.45 0 0 1-.274-.669 8.5 8.5 0 0 0-.275-.668.862.862 0 0 1-.096-.279c-.002-.156-.136-.103-.19.074a4.222 4.222 0 0 1-.148.39 67.17 67.17 0 0 0-.404.966l-.523 1.263-1.402 3.38c-.652 1.572-1.239 2.985-1.304 3.138l-.117.278h3.938c2.712 0 3.937-.024 3.937-.078Zm7.279-2.076v-9.953h4.141c4.325.002 5.108.042 5.802.3.49.183 1.248.559 1.387.688.053.05.208.172.344.274.958.712 1.874 2.135 2.223 3.455.338 1.278.2 3.018-.336 4.23-.77 1.741-2.065 2.946-3.7 3.442-.329.099-.98.122-4.123.146l-3.733.028v7.345H43.84v-9.954Zm8.815.737c1.37-.19 2.481-1.233 3.036-2.854.19-.557.234-2.096.077-2.714-.215-.84-.607-1.538-1.19-2.114-.29-.286-.626-.57-.748-.631a1.603 1.603 0 0 1-.26-.151 2.415 2.415 0 0 0-.37-.184c-.313-.135-.567-.146-3.845-.168l-3.51-.024v8.92h3.115c1.826 0 3.355-.033 3.695-.08Zm4.16 9.161c-.018-.03.096-.356.252-.724.157-.368.574-1.37.926-2.229.353-.857.686-1.66.741-1.782.055-.123.239-.557.408-.966.296-.715.456-1.096.595-1.411.036-.082.203-.483.372-.891.168-.41.35-.844.404-.966.054-.123.27-.64.48-1.151l.598-1.449c.252-.61 1.096-2.607 1.192-2.823.036-.081.153-.365.258-.631.106-.266.223-.55.26-.631.036-.082.138-.316.225-.52.086-.205.205-.477.264-.606.058-.129.106-.256.106-.282 0-.042.115-.32.371-.895.148-.331.36-.842.525-1.263a4.32 4.32 0 0 1 .242-.539c.047-.064.314-.092.867-.092h.8l.096.241c.195.485 1.048 2.51 1.26 2.99.036.082.202.483.37.891.167.409.335.81.373.892.037.081.321.767.63 1.522.31.756.593 1.441.63 1.523.037.082.24.566.453 1.077a268.143 268.143 0 0 0 1.554 3.677c.037.082.154.366.26.632.182.452.33.802.484 1.15.036.083.153.367.26.632.106.266.241.588.3.717s.107.257.107.285c0 .028.1.268.223.533.122.264.223.499.223.52 0 .022.048.145.106.274.06.129.194.451.3.717.107.265.225.55.261.631.258.572.373.857.373.925 0 .119-2.04.105-2.137-.015-.04-.051-.366-.811-.723-1.69a214.273 214.273 0 0 0-1.039-2.525c-.106-.266-.224-.55-.26-.632a31.823 31.823 0 0 1-.444-1.059l-.096-.242-4.419.02-4.419.019-.44 1.077-.51 1.249c-.04.094-.072.188-.072.208 0 .032-.162.414-.373.882-.036.082-.154.366-.26.632a40.8 40.8 0 0 1-.291.705c-.054.123-.209.5-.345.836l-.246.613h-1.021c-.562 0-1.036-.025-1.054-.056Zm12.949-7.783c0-.037-.256-.673-.477-1.186-.053-.123-.174-.44-.27-.706a7.963 7.963 0 0 0-.27-.668.933.933 0 0 1-.097-.246c-.001-.052-.131-.37-.372-.906a26.042 26.042 0 0 1-.261-.631 34.421 34.421 0 0 0-.291-.706c-.054-.122-.159-.39-.234-.594a6.526 6.526 0 0 0-.232-.557.926.926 0 0 1-.096-.249c0-.035-.048-.168-.107-.297a25.64 25.64 0 0 1-.38-.94 38.074 38.074 0 0 0-.635-1.541c-.128-.301-.213-.277-.34.097a5.39 5.39 0 0 1-.168.442c-.039.081-.14.315-.227.52-.086.204-.187.438-.224.52-.06.133-.868 2.065-1.864 4.456-.205.49-.401.959-.438 1.04-.036.082-.203.483-.37.891-.166.41-.352.853-.412.987s-.109.26-.109.279c0 .019 1.772.034 3.937.034s3.937-.017 3.937-.039Zm24.92 7.748c-.02-.052-.028-4.524-.018-9.937l.02-9.842h1.93l.02 4.4.019 4.402h11.661v-8.84h2.005v19.908h-2.005v-9.285H96.655l-.02 4.624-.019 4.624-.948.02c-.718.016-.958-.002-.985-.074Zm20.02-9.863v-9.953h13.073v1.857h-11.068v6.982h9.657v1.782h-9.657v7.429H128v1.857h-13.296v-9.954Z"/>
	<defs>
		<linearGradient id="a" x1="18.437" x2="28.683" y1="44.156" y2="41.307" gradientUnits="userSpaceOnUse">
			<stop stop-color="#F59723"/>
			<stop offset=".312" stop-color="#F69822"/>
			<stop offset=".838" stop-color="#E87726"/>
		</linearGradient>
		<linearGradient id="b" x1="-3.991" x2="16.849" y1="90.141" y2="45.448" gradientUnits="userSpaceOnUse">
			<stop offset=".323" stop-color="#9C2063"/>
			<stop offset=".63" stop-color="#C82037"/>
			<stop offset=".751" stop-color="#CC2135"/>
			<stop offset="1" stop-color="#E87726"/>
		</linearGradient>
		<linearGradient id="c" x1="3.002" x2="15.421" y1="86.834" y2="60.201" gradientUnits="userSpaceOnUse">
			<stop stop-color="#282661"/>
			<stop offset=".095" stop-color="#662E8C"/>
			<stop offset=".788" stop-color="#9E2064"/>
			<stop offset=".949" stop-color="#CC2032"/>
		</linearGradient>
		<linearGradient id="d" x1="-3.24" x2="17.6" y1="87.435" y2="42.743" gradientUnits="userSpaceOnUse">
			<stop offset=".323" stop-color="#9C2063"/>
			<stop offset=".63" stop-color="#C82037"/>
			<stop offset=".751" stop-color="#CC2135"/>
			<stop offset="1" stop-color="#E87726"/>
		</linearGradient>
		<linearGradient id="e" x1="-1.114" x2="9.839" y1="84.459" y2="60.971" gradientUnits="userSpaceOnUse">
			<stop stop-color="#282661"/>
			<stop offset=".095" stop-color="#662E8C"/>
			<stop offset=".788" stop-color="#9E2064"/>
			<stop offset=".949" stop-color="#CC2032"/>
		</linearGradient>
		<linearGradient id="f" x1="1.387" x2="22.228" y1="89.593" y2="44.9" gradientUnits="userSpaceOnUse">
			<stop offset=".323" stop-color="#9C2063"/>
			<stop offset=".63" stop-color="#C82037"/>
			<stop offset=".751" stop-color="#CC2135"/>
			<stop offset="1" stop-color="#E87726"/>
		</linearGradient>
		<linearGradient id="g" x1="-.137" x2="20.703" y1="92.257" y2="47.565" gradientUnits="userSpaceOnUse">
			<stop offset=".323" stop-color="#9C2063"/>
			<stop offset=".63" stop-color="#C82037"/>
			<stop offset=".751" stop-color="#CC2135"/>
			<stop offset="1" stop-color="#E87726"/>
		</linearGradient>
		<linearGradient id="h" x1="2.761" x2="23.601" y1="90.233" y2="45.541" gradientUnits="userSpaceOnUse">
			<stop offset=".323" stop-color="#9C2063"/>
			<stop offset=".63" stop-color="#C82037"/>
			<stop offset=".751" stop-color="#CC2135"/>
			<stop offset="1" stop-color="#E87726"/>
		</linearGradient>
		<linearGradient id="i" x1="2.605" x2="23.445" y1="90.161" y2="45.468" gradientUnits="userSpaceOnUse">
			<stop offset=".323" stop-color="#9C2063"/>
			<stop offset=".63" stop-color="#C82037"/>
			<stop offset=".751" stop-color="#CC2135"/>
			<stop offset="1" stop-color="#E87726"/>
		</linearGradient>
		<linearGradient id="j" x1="14.281" x2="18.887" y1="65.038" y2="55.16" gradientUnits="userSpaceOnUse">
			<stop offset=".323" stop-color="#9C2063"/>
			<stop offset=".63" stop-color="#C82037"/>
			<stop offset=".751" stop-color="#CC2135"/>
			<stop offset="1" stop-color="#E87726"/>
		</linearGradient>
	</defs>
</svg>

@SethFalco SethFalco reopened this Dec 9, 2023
@KTibow
Copy link
Contributor

KTibow commented Dec 9, 2023

Can't reproduce in my tests with upstream SVGO, using plugins: ['preset-default', 'reusePaths']

@cyberalien
Copy link
Contributor Author

Can't reproduce in my tests with upstream SVGO, using plugins: ['preset-default', 'reusePaths']

Try with plugins listed in first post: ['removeHiddenElems', 'convertPathData', 'reusePaths']

@KTibow
Copy link
Contributor

KTibow commented Dec 9, 2023

Using this code on upstream:
test.js * had to convert to zip because github blocks js
Produces this output:
result
Which I see nothing wrong with, both visually and in the code.

@cyberalien
Copy link
Contributor Author

It contains <use xlink:href="#reuse-2"/><use opacity=".35" xlink:href="#reuse-2"/>, but no element with id reuse-2

@KTibow
Copy link
Contributor

KTibow commented Dec 9, 2023

Ah missed that, I'll investigate

@KTibow
Copy link
Contributor

KTibow commented Dec 9, 2023

Problem is caused by assuming that defs comes first, this can be fixed by running the logic at root.exit, I'll see if I can make a PR for this

@cyberalien
Copy link
Contributor Author

Awesome. Thanks a lot for fixing it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants