1
0
mirror of https://github.com/svg/svgo.git synced 2025-07-29 20:21:14 +03:00

Prepare root and element nodes for xast

Ref https://github.com/syntax-tree/xast

- added type: root | element
- renamed elem to name
- replaced "elem" property checks with check for correct type
This commit is contained in:
Bogdan Chadkin
2021-03-10 18:45:50 +03:00
parent 54daf72d50
commit e82a672bbf
29 changed files with 95 additions and 80 deletions

View File

@ -81,7 +81,7 @@ function findStyleElems(ast) {
if (item.isElem('style') && !item.isEmpty()) {
styles.push(item);
} else if (item.isElem() && item.hasAttr('style')) {
} else if (item.type === 'element' && item.hasAttr('style')) {
styles.push(item);
}
}
@ -118,8 +118,8 @@ function collectUsageData(ast, options) {
safe = false;
}
if (item.isElem()) {
usageData.tags[item.elem] = true;
if (item.type === 'element') {
usageData.tags[item.name] = true;
if (item.hasAttr('id')) {
usageData.ids[item.attr('id').value] = true;