Skip to content

Commit

Permalink
Prevent removing groups that are direct child of "<switch>". Fix svg#845
Browse files Browse the repository at this point in the history
  • Loading branch information
GreLI committed Nov 21, 2017
1 parent a6d2c88 commit eb3b4b8
Showing 1 changed file with 1 addition and 10 deletions.
11 changes: 1 addition & 10 deletions plugins/collapseGroups.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,10 @@ function hasAnimatedAttr(item) {
exports.fn = function(item) {

// non-empty elements
if (item.isElem() && !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()) {

// move group attibutes to the single content element
if (g.hasAttr() && g.content.length === 1) {
var inner = g.content[0];
Expand Down Expand Up @@ -82,21 +79,15 @@ exports.fn = function(item) {
if (!g.hasAttr() && !g.content.some(function(item) { return item.isElem(animationElems) })) {
item.spliceContent(i, 1, g.content);
}


} else if (g.isElem('switch') && !g.isEmpty()) {
// check if one of the direct children has requiredFeatures, requiredExtensions or systemLanguage attributes else remove

if (!g.content || !g.content.some(function(child) {
return child.hasAttr('systemLanguage') || child.hasAttr('requiredFeatures') || child.hasAttr('requiredExtensions');
})
) {
item.spliceContent(i, 1, g.content);
}
}

});

}

};

0 comments on commit eb3b4b8

Please sign in to comment.