Skip to content

Commit

Permalink
fix(convertPathData): fix q control point behavior when item is remov…
Browse files Browse the repository at this point in the history
…ed (#1927)
  • Loading branch information
KTibow authored Jan 6, 2024
1 parent 9e01769 commit 6afc7bd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
3 changes: 2 additions & 1 deletion plugins/convertPathData.js
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,6 @@ function filters(

path = path.filter(function (item, index, path) {
const qControlPoint = prevQControlPoint;
prevQControlPoint = undefined;

let command = item.command;
let data = item.args;
Expand Down Expand Up @@ -895,6 +894,8 @@ function filters(
// @ts-ignore
prevQControlPoint = item.coords;
}
} else {
prevQControlPoint = undefined;
}
prev = item;
return true;
Expand Down
15 changes: 15 additions & 0 deletions test/plugins/convertPathData.36.svg.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Should process/optimize q correctly even if useless commands in between.

See: https://github.com/svg/svgo/issues/1926

===

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1 20">
<path d="M-6.3 9.9q.7-4.5.2-5-.5-.5-1.5-.5l0 0q-.4 0-2 .3"/>
</svg>

@@@

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1 20">
<path d="M-6.3 9.9q.7-4.5.2-5t-1.5-.5q-.4 0-2 .3"/>
</svg>

0 comments on commit 6afc7bd

Please sign in to comment.