From 713690cca266116bb7e80d13cf84bc843f9dfd52 Mon Sep 17 00:00:00 2001 From: Chris Hull Date: Tue, 23 Apr 2024 07:09:37 -0400 Subject: [PATCH] fix: support values of `0` in stroke-dasharray (#2721) --- .changeset/pretty-humans-add.md | 5 +++++ packages/pdfkit/src/mixins/vector.js | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 .changeset/pretty-humans-add.md diff --git a/.changeset/pretty-humans-add.md b/.changeset/pretty-humans-add.md new file mode 100644 index 000000000..4466b3454 --- /dev/null +++ b/.changeset/pretty-humans-add.md @@ -0,0 +1,5 @@ +--- +"@react-pdf/pdfkit": patch +--- + +fix: support values of `0` in stroke-dasharray diff --git a/packages/pdfkit/src/mixins/vector.js b/packages/pdfkit/src/mixins/vector.js index 5f58bbb16..3ca0341bf 100644 --- a/packages/pdfkit/src/mixins/vector.js +++ b/packages/pdfkit/src/mixins/vector.js @@ -67,12 +67,12 @@ export default { length = [length, options.space || length]; } - const valid = length.every((x) => Number.isFinite(x) && x > 0); + const valid = length.every((x) => Number.isFinite(x) && x >= 0); if (!valid) { throw new Error( `dash(${JSON.stringify(originalLength)}, ${JSON.stringify( options - )}) invalid, lengths must be numeric and greater than zero` + )}) invalid, lengths must be numeric and greater than or equal to zero` ); }