diff --git a/packages/utils/package.json b/packages/utils/package.json index 35603d7..ccafb47 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -3,7 +3,7 @@ "type": "module", "description": "Common functions for working with Iconify icon sets used by various packages.", "author": "Vjacheslav Trushkin", - "version": "1.0.25", + "version": "1.0.26", "license": "MIT", "bugs": "https://github.com/iconify/iconify/issues", "homepage": "https://iconify.design/", diff --git a/packages/utils/src/loader/utils.ts b/packages/utils/src/loader/utils.ts index 77cbb63..4ad4a4c 100644 --- a/packages/utils/src/loader/utils.ts +++ b/packages/utils/src/loader/utils.ts @@ -70,17 +70,16 @@ export async function mergeIconProps( } } - svg = svg.replace( - ' - (p === 'width' && widthOnSvg) || (p === 'height' && heightOnSvg) - ? null - : `${p}="${props[p]}"` - ) - .filter((p) => p != null) - .join(' ')} ` - ); + const propsToAdd = Object.keys(props) + .map((p) => + (p === 'width' && widthOnSvg) || (p === 'height' && heightOnSvg) + ? null + : `${p}="${props[p]}"` + ) + .filter((p) => p != null); + if (propsToAdd.length) { + svg = svg.replace(' { expect(svg).toEqual(result); }); + test('CustomIconLoader without xmlns', async () => { + const svg = + ''; + const result = await getCustomIcon(() => svg, 'a', 'b', { + addXmlNs: true, + }); + expect(result).toEqual( + '' + ); + }); + test("CustomIconLoader with transform: scale/width/height shouldn't take effect", async () => { const svg = await fs.readFile(fixturesDir + '/circle.svg', 'utf8'); const options: IconifyLoaderOptions = {