mirror of
https://github.com/iconify/iconify.git
synced 2025-01-22 14:48:24 +00:00
fix(utils): in generated css merge identical selectors
This commit is contained in:
parent
bba91bc538
commit
a742cf1d94
@ -120,11 +120,21 @@ export function getIconsCSS(
|
|||||||
const selector = Array.from(commonSelectors).join(
|
const selector = Array.from(commonSelectors).join(
|
||||||
newOptions.format === 'compressed' ? ',' : ', '
|
newOptions.format === 'compressed' ? ',' : ', '
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Check for same selector
|
||||||
|
if (css.length === 1 && css[0].selector === selector) {
|
||||||
|
css[0].rules = {
|
||||||
|
// Common first, override later
|
||||||
|
...commonRules,
|
||||||
|
...css[0].rules,
|
||||||
|
};
|
||||||
|
} else {
|
||||||
css.unshift({
|
css.unshift({
|
||||||
selector,
|
selector,
|
||||||
rules: commonRules,
|
rules: commonRules,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Format
|
// Format
|
||||||
return (
|
return (
|
||||||
|
@ -320,17 +320,13 @@ describe('Testing CSS for multiple icons', () => {
|
|||||||
})
|
})
|
||||||
).toBe(`.test--activity {
|
).toBe(`.test--activity {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
width: 1em;
|
width: 1.5em;
|
||||||
height: 1em;
|
height: 1em;
|
||||||
background-color: currentColor;
|
background-color: currentColor;
|
||||||
-webkit-mask: no-repeat center / 100%;
|
-webkit-mask: no-repeat center / 100%;
|
||||||
mask: no-repeat center / 100%;
|
mask: no-repeat center / 100%;
|
||||||
-webkit-mask-image: var(--svg);
|
-webkit-mask-image: var(--svg);
|
||||||
mask-image: var(--svg);
|
mask-image: var(--svg);
|
||||||
}
|
|
||||||
|
|
||||||
.test--activity {
|
|
||||||
width: 1.5em;
|
|
||||||
--svg: ${expectedURL('activity')};
|
--svg: ${expectedURL('activity')};
|
||||||
}
|
}
|
||||||
`);
|
`);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user