1
0
mirror of https://github.com/svg/svgo.git synced 2025-07-31 07:44:22 +03:00

Drop node.class usages (#1533)

We are gonna remove everything outside of xast.
Here's dropped class prop.
This commit is contained in:
Bogdan Chadkin
2021-08-21 19:42:32 +03:00
committed by GitHub
parent e4918ccdd1
commit 98c023bdb0
4 changed files with 38 additions and 15 deletions

View File

@ -69,8 +69,17 @@ exports.fn = (root, params) => {
element: {
enter: (node, parentNode) => {
if (node.name === 'svg' && parentNode.type === 'root') {
// @ts-ignore class attribute will be just a string eventually
node.class.add(...classNames);
const classList = new Set(
node.attributes.class == null
? null
: node.attributes.class.split(' ')
);
for (const className of classNames) {
if (className != null) {
classList.add(className);
}
}
node.attributes.class = Array.from(classList).join(' ');
}
},
},