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

Migrate ast traversing into xast module (#1434)

Replaced JSAPI methods with new utilities

- querySelectorAll(node, selector)
- querySelector(node, selector)
- matches(node, selector)
- closestByName(node, elementName)
- traverse(node, fn)

New traverse replaced many in-place implementations.
This commit is contained in:
Bogdan Chadkin
2021-03-19 11:06:41 +03:00
committed by GitHub
parent 6f2f62c5ee
commit 4cacd9e676
10 changed files with 294 additions and 303 deletions

View File

@ -1,5 +1,7 @@
'use strict';
const { closestByName } = require('../lib/xast.js');
exports.type = 'perItem';
exports.active = true;
@ -32,7 +34,7 @@ exports.fn = function (item) {
item.attributes.height != null
) {
// TODO remove width/height for such case instead
if (item.name === 'svg' && item.closestElem('svg')) {
if (item.name === 'svg' && closestByName(item.parentNode, 'svg')) {
return;
}