Skip to content

Commit

Permalink
Fix cleanupIDs if defs is last elem of svg
Browse files Browse the repository at this point in the history
  • Loading branch information
alexpavlovich authored and GreLI committed Nov 9, 2019
1 parent 1152257 commit 7746480
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 3 deletions.
8 changes: 5 additions & 3 deletions plugins/cleanupIDs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
41 changes: 41 additions & 0 deletions test/plugins/cleanupIDs.20.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 7746480

Please sign in to comment.