mirror of
https://github.com/iconify/iconify.git
synced 2025-01-08 15:54:09 +00:00
Fix double spacing in attributes in mergeIconProps in utils
This commit is contained in:
parent
29a88a2753
commit
a7899d812f
@ -3,7 +3,7 @@
|
|||||||
"type": "module",
|
"type": "module",
|
||||||
"description": "Common functions for working with Iconify icon sets used by various packages.",
|
"description": "Common functions for working with Iconify icon sets used by various packages.",
|
||||||
"author": "Vjacheslav Trushkin",
|
"author": "Vjacheslav Trushkin",
|
||||||
"version": "1.0.25",
|
"version": "1.0.26",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"bugs": "https://github.com/iconify/iconify/issues",
|
"bugs": "https://github.com/iconify/iconify/issues",
|
||||||
"homepage": "https://iconify.design/",
|
"homepage": "https://iconify.design/",
|
||||||
|
@ -70,17 +70,16 @@ export async function mergeIconProps(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
svg = svg.replace(
|
const propsToAdd = Object.keys(props)
|
||||||
'<svg ',
|
|
||||||
`<svg ${Object.keys(props)
|
|
||||||
.map((p) =>
|
.map((p) =>
|
||||||
(p === 'width' && widthOnSvg) || (p === 'height' && heightOnSvg)
|
(p === 'width' && widthOnSvg) || (p === 'height' && heightOnSvg)
|
||||||
? null
|
? null
|
||||||
: `${p}="${props[p]}"`
|
: `${p}="${props[p]}"`
|
||||||
)
|
)
|
||||||
.filter((p) => p != null)
|
.filter((p) => p != null);
|
||||||
.join(' ')} `
|
if (propsToAdd.length) {
|
||||||
);
|
svg = svg.replace('<svg ', `<svg ${propsToAdd.join(' ')} `);
|
||||||
|
}
|
||||||
|
|
||||||
if (svg && options) {
|
if (svg && options) {
|
||||||
const { defaultStyle, defaultClass } = options;
|
const { defaultStyle, defaultClass } = options;
|
||||||
|
@ -11,6 +11,17 @@ describe('Testing getCustomIcon', () => {
|
|||||||
expect(svg).toEqual(result);
|
expect(svg).toEqual(result);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('CustomIconLoader without xmlns', async () => {
|
||||||
|
const svg =
|
||||||
|
'<svg viewBox="0 0 120 120"><circle cx="60" cy="60" r="50"/></svg>';
|
||||||
|
const result = await getCustomIcon(() => svg, 'a', 'b', {
|
||||||
|
addXmlNs: true,
|
||||||
|
});
|
||||||
|
expect(result).toEqual(
|
||||||
|
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 120 120"><circle cx="60" cy="60" r="50"/></svg>'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
test("CustomIconLoader with transform: scale/width/height shouldn't take effect", async () => {
|
test("CustomIconLoader with transform: scale/width/height shouldn't take effect", async () => {
|
||||||
const svg = await fs.readFile(fixturesDir + '/circle.svg', 'utf8');
|
const svg = await fs.readFile(fixturesDir + '/circle.svg', 'utf8');
|
||||||
const options: IconifyLoaderOptions = {
|
const options: IconifyLoaderOptions = {
|
||||||
|
Loading…
Reference in New Issue
Block a user