diff --git a/plugins/cleanupIDs.js b/plugins/cleanupIDs.js index aebec051..71ffb5f9 100644 --- a/plugins/cleanupIDs.js +++ b/plugins/cleanupIDs.js @@ -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; } diff --git a/test/plugins/cleanupIDs.20.svg b/test/plugins/cleanupIDs.20.svg new file mode 100644 index 00000000..2fa08694 --- /dev/null +++ b/test/plugins/cleanupIDs.20.svg @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + +@@@ + + + + + + + + + + + + + + + + + + + +@@@ + +{"prefix": "test__", "remove": "false"}