Skip to content

Commit

Permalink
fix: Avoid appending redundant def object
Browse files Browse the repository at this point in the history
  • Loading branch information
miyanokomiya committed Feb 10, 2024
1 parent d4ffc7d commit 7ff8d90
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/composables/shapeSVGRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ export function newShapeSVGRenderer(option: Option) {
// Embed asset files used in this SVG.
const usedAssetIdSet = new Set();
const assetDef = createSVGElement("def");
root.appendChild(assetDef);
root.querySelectorAll("use[href]").forEach((elm) => {
const assetId = (elm as SVGUseElement).href.baseVal.slice(1);
if (usedAssetIdSet.has(assetId)) return;
Expand All @@ -77,6 +76,9 @@ export function newShapeSVGRenderer(option: Option) {
});
assetDef.appendChild(imageElm);
});
if (assetDef.children.length > 0) {
root.prepend(assetDef);
}

return root;
}
Expand Down

0 comments on commit 7ff8d90

Please sign in to comment.