Skip to content

Commit

Permalink
Prevented collapsing group with passing animated attribute
Browse files Browse the repository at this point in the history
Fixes #534
  • Loading branch information
GreLI committed Apr 25, 2016
1 parent 7d556d0 commit 2bbabee
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
7 changes: 7 additions & 0 deletions plugins/collapseGroups.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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') {
Expand Down
12 changes: 12 additions & 0 deletions test/plugins/collapseGroups.11.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 2bbabee

Please sign in to comment.