Skip to content

Commit

Permalink
Fix collapseGroups plugin affecting switch and subgroups
Browse files Browse the repository at this point in the history
  • Loading branch information
GreLI committed Sep 16, 2018
1 parent 5800635 commit 7a07b84
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
10 changes: 1 addition & 9 deletions plugins/collapseGroups.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function hasAnimatedAttr(item) {
exports.fn = function(item) {

// non-empty elements
if (item.isElem() && (!item.isElem('switch') || isFeaturedSwitch(item)) && !item.isEmpty()) {
if (item.isElem() && !item.isElem('switch') && !item.isEmpty()) {
item.content.forEach(function(g, i) {
// non-empty groups
if (g.isElem('g') && !g.isEmpty()) {
Expand Down Expand Up @@ -81,15 +81,7 @@ exports.fn = function(item) {
if (!g.hasAttr() && !g.content.some(function(item) { return item.isElem(animationElems) })) {
item.spliceContent(i, 1, g.content);
}
} else if (isFeaturedSwitch(g)) {
item.spliceContent(i, 1, g.content);
}
});
}
};

function isFeaturedSwitch(elem) {
return elem.isElem('switch') && !elem.isEmpty() && !elem.content.some(child =>
child.hasAttr('systemLanguage') || child.hasAttr('requiredFeatures') || child.hasAttr('requiredExtensions')
);
}
18 changes: 12 additions & 6 deletions test/plugins/collapseGroups.14.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 7a07b84

Please sign in to comment.