diff --git a/plugins/collapseGroups.js b/plugins/collapseGroups.js index fc7d90124..8d82a7257 100644 --- a/plugins/collapseGroups.js +++ b/plugins/collapseGroups.js @@ -8,6 +8,11 @@ exports.description = 'collapses useless groups'; var animationElems = require('./_collections').elemsGroups.animation; +function hasAnimatedAttr(item) { + return item.isElem(animationElems) && item.hasAttr('attributeName', this) || + !item.isEmpty() && item.content.some(hasAnimatedAttr, this); +} + /* * Collapse useless groups. * @@ -50,6 +55,8 @@ exports.fn = function(item) { inner.isElem('g') && !g.hasAttr('transform') && !inner.hasAttr('transform') )) { g.eachAttr(function(attr) { + if (g.content.some(hasAnimatedAttr, attr.name)) return; + if (!inner.hasAttr(attr.name)) { inner.addAttr(attr); } else if (attr.name == 'transform' || attr.name == 'class') { diff --git a/test/plugins/collapseGroups.11.svg b/test/plugins/collapseGroups.11.svg index e10a2a530..dff1b33da 100644 --- a/test/plugins/collapseGroups.11.svg +++ b/test/plugins/collapseGroups.11.svg @@ -10,6 +10,12 @@ + + + + + + @@@ @@ -26,4 +32,10 @@ + + + + + +