diff --git a/lib/svgo.test.js b/lib/svgo.test.js index ecf303608..a1570b35e 100644 --- a/lib/svgo.test.js +++ b/lib/svgo.test.js @@ -395,7 +395,7 @@ test('encode as datauri', () => { plugins: ['convertTransform'], }); expect(dataSinglePass).toMatchInlineSnapshot( - `"data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cg%20transform%3D%22scale(2)%20rotate(-45%20130.898%20-126.14)%22%2F%3E%3C%2Fsvg%3E"` + `"data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cg%20transform%3D%22scale(2)rotate(-45%20130.898%20-126.14)%22%2F%3E%3C%2Fsvg%3E"` ); const { data: dataMultiPass } = optimize(input, { multipass: true, @@ -403,6 +403,6 @@ test('encode as datauri', () => { plugins: ['convertTransform'], }); expect(dataMultiPass).toMatchInlineSnapshot( - `"data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cg%20transform%3D%22rotate(-45%20261.796%20-252.28)%20scale(2)%22%2F%3E%3C%2Fsvg%3E"` + `"data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cg%20transform%3D%22rotate(-45%20261.796%20-252.28)scale(2)%22%2F%3E%3C%2Fsvg%3E"` ); }); diff --git a/plugins/convertTransform.js b/plugins/convertTransform.js index d90c3efdb..60e0214f5 100644 --- a/plugins/convertTransform.js +++ b/plugins/convertTransform.js @@ -335,18 +335,12 @@ const removeUseless = (transforms) => { * @type {(transformJS: Array, params: TransformParams) => string} */ const js2transform = (transformJS, params) => { - var transformString = ''; - - // collect output value string - transformJS.forEach((transform) => { - roundTransform(transform, params); - transformString += - (transformString && ' ') + - transform.name + - '(' + - cleanupOutData(transform.data, params) + - ')'; - }); + const transformString = transformJS + .map((transform) => { + roundTransform(transform, params); + return `${transform.name}(${cleanupOutData(transform.data, params)})`; + }) + .join(''); return transformString; }; diff --git a/test/coa/testSvg/test.1.svg b/test/coa/testSvg/test.1.svg index 1dcbceb77..6e9bd7640 100644 --- a/test/coa/testSvg/test.1.svg +++ b/test/coa/testSvg/test.1.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/test/coa/testSvg/test.svg b/test/coa/testSvg/test.svg index 1dcbceb77..6e9bd7640 100644 --- a/test/coa/testSvg/test.svg +++ b/test/coa/testSvg/test.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/test/plugins/convertTransform.01.svg b/test/plugins/convertTransform.01.svg index 08b77701c..b7721db28 100644 --- a/test/plugins/convertTransform.01.svg +++ b/test/plugins/convertTransform.01.svg @@ -25,19 +25,19 @@ - - + + - + - - + + - + diff --git a/test/plugins/convertTransform.02.svg b/test/plugins/convertTransform.02.svg index 46b2882a2..2b3a35bf3 100644 --- a/test/plugins/convertTransform.02.svg +++ b/test/plugins/convertTransform.02.svg @@ -15,9 +15,9 @@ - - - - + + + + diff --git a/test/plugins/convertTransform.03.svg b/test/plugins/convertTransform.03.svg index 83a19ed0a..4e4a547fb 100644 --- a/test/plugins/convertTransform.03.svg +++ b/test/plugins/convertTransform.03.svg @@ -17,5 +17,5 @@ - +