2
0
mirror of https://github.com/iconify/iconify.git synced 2024-09-19 00:39:02 +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
*/
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,
end: string
): string {
const { defs, content } = splitSVGDefs(body);
return (defs ? '<defs>' + defs + '</defs>' : '') + start + content + end;
const split = splitSVGDefs(body);
return mergeDefsAndContent(split.defs, start + split.content + end);
}