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

Fix cleanupIDs if defs is last elem of svg

This commit is contained in:
alexpavlovich
2019-11-09 21:41:17 +03:00
committed by Lev Solntsev
parent 1152257505
commit 77464801e7
2 changed files with 46 additions and 3 deletions

View File

@ -63,11 +63,13 @@ exports.fn = function(data, params) {
hasStyleOrScript = true;
continue;
}
// Don't remove IDs if the whole SVG consists only of defs.
if (item.isElem('defs') && item.parentNode.isElem('svg')) {
if (item.isElem('svg')) {
var hasDefsOnly = true;
for (var j = i + 1; j < items.content.length; j++) {
if (items.content[j].isElem()) {
for (var j = 0; j < item.content.length; j++) {
if (!item.content[j].isElem('defs')) {
hasDefsOnly = false;
break;
}