From 7901588a9f18d6ef476389405a73cd7fe42ed179 Mon Sep 17 00:00:00 2001 From: Bogdan Chadkin Date: Sun, 28 Feb 2021 15:22:27 +0300 Subject: [PATCH] Fix path optimisation with stroke-linecap round Ref https://github.com/svg/svgo/issues/890 --- plugins/convertPathData.js | 8 +++++--- test/plugins/convertPathData.03.svg | 4 ++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/plugins/convertPathData.js b/plugins/convertPathData.js index f64baf28d..80c9b8651 100644 --- a/plugins/convertPathData.js +++ b/plugins/convertPathData.js @@ -69,9 +69,11 @@ exports.fn = function(item, params) { } hasMarkerMid = item.hasAttr('marker-mid'); - var stroke = item.computedAttr('stroke'), - strokeLinecap = item.computedAttr('stroke'); - hasStrokeLinecap = stroke && stroke != 'none' && strokeLinecap && strokeLinecap != 'butt'; + const stroke = item.computedAttr('stroke'); + const strokeLinecap = item.computedAttr('stroke-linecap'); + // stroke-linecap may exist in inline styles which are not parsed for now + hasStrokeLinecap = item.hasAttr('style') || + stroke && stroke != 'none' && strokeLinecap && strokeLinecap != 'butt'; var data = path2js(item); diff --git a/test/plugins/convertPathData.03.svg b/test/plugins/convertPathData.03.svg index 8081173d1..05cb5e7ad 100644 --- a/test/plugins/convertPathData.03.svg +++ b/test/plugins/convertPathData.03.svg @@ -15,6 +15,8 @@ + + @@@ @@ -36,4 +38,6 @@ + +