Skip to content

Commit

Permalink
Don't collapse a group with element when both have classes.
Browse files Browse the repository at this point in the history
Fixes svg#572 (comment)
  • Loading branch information
GreLI committed Aug 24, 2016
1 parent 44d6958 commit 6e9854a
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 5 deletions.
12 changes: 7 additions & 5 deletions plugins/collapseGroups.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,18 @@ exports.fn = function(item) {
if (g.hasAttr() && g.content.length === 1) {
var inner = g.content[0];

if (inner.isElem() && !inner.hasAttr('id') && (
!g.hasAttr('clip-path') && !g.hasAttr('mask') ||
inner.isElem('g') && !g.hasAttr('transform') && !inner.hasAttr('transform')
)) {
if (inner.isElem() && !inner.hasAttr('id') &&
!(g.hasAttr('class') && inner.hasAttr('class')) && (
!g.hasAttr('clip-path') && !g.hasAttr('mask') ||
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') {
} else if (attr.name == 'transform') {
inner.attr(attr.name).value = attr.value + ' ' + inner.attr(attr.name).value;
}
g.removeAttr(attr.name);
Expand Down
24 changes: 24 additions & 0 deletions test/plugins/collapseGroups.12.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 6e9854a

Please sign in to comment.