2
0
mirror of https://github.com/iconify/iconify.git synced 2025-01-06 07:20:40 +00:00

fix(utils): in generated css merge identical selectors

This commit is contained in:
Vjacheslav Trushkin 2023-01-06 21:01:51 +02:00
parent bba91bc538
commit a742cf1d94
2 changed files with 15 additions and 9 deletions

View File

@ -120,10 +120,20 @@ export function getIconsCSS(
const selector = Array.from(commonSelectors).join(
newOptions.format === 'compressed' ? ',' : ', '
);
css.unshift({
selector,
rules: commonRules,
});
// 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({
selector,
rules: commonRules,
});
}
}
// Format

View File

@ -320,17 +320,13 @@ describe('Testing CSS for multiple icons', () => {
})
).toBe(`.test--activity {
display: inline-block;
width: 1em;
width: 1.5em;
height: 1em;
background-color: currentColor;
-webkit-mask: no-repeat center / 100%;
mask: no-repeat center / 100%;
-webkit-mask-image: var(--svg);
mask-image: var(--svg);
}
.test--activity {
width: 1.5em;
--svg: ${expectedURL('activity')};
}
`);