2
0
mirror of https://github.com/iconify/iconify.git synced 2025-01-07 07:34:22 +00:00

chore: do not create empty defs in mergeDefsAndContent

This commit is contained in:
Vjacheslav Trushkin 2023-08-19 21:38:46 +03:00
parent 35b92a4cd5
commit d8781fc7e4

View File

@ -34,7 +34,7 @@ export function splitSVGDefs(content: string): SplitSVGDefsResult {
* Merge defs and content * Merge defs and content
*/ */
export function mergeDefsAndContent(defs: string, content: string): string { export function mergeDefsAndContent(defs: string, content: string): string {
return '<defs>' + defs + '</defs>' + content; return defs ? '<defs>' + defs + '</defs>' + content : content;
} }
/** /**
@ -45,6 +45,6 @@ export function wrapSVGContent(
start: string, start: string,
end: string end: string
): string { ): string {
const { defs, content } = splitSVGDefs(body); const split = splitSVGDefs(body);
return (defs ? '<defs>' + defs + '</defs>' : '') + start + content + end; return mergeDefsAndContent(split.defs, start + split.content + end);
} }