mirror of
https://github.com/svg/svgo.git
synced 2025-07-31 07:44:22 +03:00
plugins/moveElemsAttrsToGroup: merge split-level transforms instead of replacing (fix #10)
This commit is contained in:
@ -29,6 +29,7 @@ exports.moveElemsAttrsToGroup = function(item, params) {
|
||||
if (item.isElem('g') && !item.isEmpty() && item.content.length > 1) {
|
||||
|
||||
var intersection = {},
|
||||
hasTransform = false,
|
||||
every = item.content.every(function(g) {
|
||||
if (g.elem && g.attrs) {
|
||||
if (!Object.keys(intersection).length) {
|
||||
@ -48,7 +49,15 @@ exports.moveElemsAttrsToGroup = function(item, params) {
|
||||
item.content.forEach(function(g) {
|
||||
for (var name in intersection) {
|
||||
g.removeAttr(name);
|
||||
item.addAttr(intersection[name]);
|
||||
|
||||
if (name === 'transform') {
|
||||
if (!hasTransform) {
|
||||
item.attr('transform').value += ' ' + intersection[name].value;
|
||||
hasTransform = true;
|
||||
}
|
||||
} else {
|
||||
item.addAttr(intersection[name]);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user