mirror of
https://github.com/svg/svgo.git
synced 2025-07-29 20:21:14 +03:00
Remove flag spaces for all arcs (#1484)
Ref #1476 The issue is that a path command may have multiple arcs, and the space optimization was only applied to the first one. Modified a test to check it. Co-authored-by: Josep del Río <joseprio@fb.com> Co-authored-by: Bogdan Chadkin <trysound@yandex.ru>
This commit is contained in:
@ -278,7 +278,8 @@ const stringifyArgs = ({
|
|||||||
if (
|
if (
|
||||||
disableSpaceAfterFlags &&
|
disableSpaceAfterFlags &&
|
||||||
(command === 'A' || command === 'a') &&
|
(command === 'A' || command === 'a') &&
|
||||||
(i === 4 || i === 5)
|
// consider combined arcs
|
||||||
|
(i % 7 === 4 || i % 7 === 5)
|
||||||
) {
|
) {
|
||||||
result += numberString;
|
result += numberString;
|
||||||
} else if (i === 0 || numberString.startsWith('-')) {
|
} else if (i === 0 || numberString.startsWith('-')) {
|
||||||
|
@ -165,18 +165,19 @@ describe('stringify path data', () => {
|
|||||||
{ command: 'M', args: [0, 0] },
|
{ command: 'M', args: [0, 0] },
|
||||||
{ command: 'A', args: [50, 50, 10, 1, 0, 0.2, 20] },
|
{ command: 'A', args: [50, 50, 10, 1, 0, 0.2, 20] },
|
||||||
{ command: 'a', args: [50, 50, 10, 1, 0, 0.2, 20] },
|
{ command: 'a', args: [50, 50, 10, 1, 0, 0.2, 20] },
|
||||||
|
{ command: 'a', args: [50, 50, 10, 1, 0, 0.2, 20] },
|
||||||
];
|
];
|
||||||
expect(
|
expect(
|
||||||
stringifyPathData({
|
stringifyPathData({
|
||||||
pathData,
|
pathData,
|
||||||
disableSpaceAfterFlags: false,
|
disableSpaceAfterFlags: false,
|
||||||
})
|
})
|
||||||
).toEqual('M0 0A50 50 10 1 0 .2 20a50 50 10 1 0 .2 20');
|
).toEqual('M0 0A50 50 10 1 0 .2 20a50 50 10 1 0 .2 20 50 50 10 1 0 .2 20');
|
||||||
expect(
|
expect(
|
||||||
stringifyPathData({
|
stringifyPathData({
|
||||||
pathData,
|
pathData,
|
||||||
disableSpaceAfterFlags: true,
|
disableSpaceAfterFlags: true,
|
||||||
})
|
})
|
||||||
).toEqual('M0 0A50 50 10 10.2 20a50 50 10 10.2 20');
|
).toEqual('M0 0A50 50 10 10.2 20a50 50 10 10.2 20 50 50 10 10.2 20');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user