Skip to content

Commit

Permalink
Fix empty path segments removing with stroke-linecap
Browse files Browse the repository at this point in the history
  • Loading branch information
GreLI committed Sep 16, 2018
1 parent a165206 commit 831f95f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 7 additions & 2 deletions plugins/convertPathData.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ var pathElems = require('./_collections.js').pathElems,
error,
arcThreshold,
arcTolerance,
hasMarkerMid;
hasMarkerMid,
hasStrokeLinecap;

/**
* Convert absolute Path to relative,
Expand Down Expand Up @@ -67,6 +68,10 @@ 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';

var data = path2js(item);

// TODO: get rid of functions returns
Expand Down Expand Up @@ -584,7 +589,7 @@ function filters(path, params) {
}

// remove useless non-first path segments
if (params.removeUseless) {
if (params.removeUseless && !hasStrokeLinecap) {

// l 0,0 / h 0 / v 0 / q 0,0 0,0 / t 0,0 / c 0,0 0,0 0,0 / s 0,0 0,0
if (
Expand Down
2 changes: 2 additions & 0 deletions test/plugins/convertPathData.03.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 831f95f

Please sign in to comment.