From 03bde9387aabeed5d9a589004a6463f70682d094 Mon Sep 17 00:00:00 2001 From: Zhicheng Chen Date: Mon, 16 Mar 2026 15:30:56 +0800 Subject: [PATCH 1/5] fix text when x is null --- lib/mixins/text.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/mixins/text.js b/lib/mixins/text.js index 82906531..bd16d711 100644 --- a/lib/mixins/text.js +++ b/lib/mixins/text.js @@ -389,7 +389,7 @@ export default { }, _initOptions(x = {}, y, options = {}) { - if (typeof x === 'object') { + if (x && typeof x === 'object') { options = x; x = null; } @@ -433,7 +433,7 @@ export default { } // 1/4 inch // Normalize rotation to between 0 - 360 - result.rotation = Number(options.rotation ?? 0) % 360; + result.rotation = Number(options?.rotation ?? 0) % 360; if (result.rotation < 0) result.rotation += 360; return result; From e68837423df4ae82d5ef69220e37faac36d62950 Mon Sep 17 00:00:00 2001 From: Zhicheng Chen Date: Mon, 16 Mar 2026 15:49:22 +0800 Subject: [PATCH 2/5] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 70efaa2f..0fb05cb5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - Bump node version requirement to 20+ - Bump minimum supported browsers to Firefox 115, iOS/Safari 16 +- Fix text with input x as null ### [v0.18.0] - 2026-03-14 From 75036c3c8205484a327281c343c6a8da5b2ba158 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Am=C3=A9rico?= Date: Mon, 16 Mar 2026 07:54:44 -0300 Subject: [PATCH 3/5] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- lib/mixins/text.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/mixins/text.js b/lib/mixins/text.js index bd16d711..f83d8ba7 100644 --- a/lib/mixins/text.js +++ b/lib/mixins/text.js @@ -433,7 +433,7 @@ export default { } // 1/4 inch // Normalize rotation to between 0 - 360 - result.rotation = Number(options?.rotation ?? 0) % 360; + result.rotation = Number(result.rotation ?? 0) % 360; if (result.rotation < 0) result.rotation += 360; return result; From 4afdc307126b23957c4553e7cce96adb5627f98c Mon Sep 17 00:00:00 2001 From: Zhicheng Chen Date: Tue, 17 Mar 2026 11:12:12 +0800 Subject: [PATCH 4/5] Add unit test for text when x is null --- tests/unit/text.spec.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/unit/text.spec.js b/tests/unit/text.spec.js index 8d6cc7e7..26849264 100644 --- a/tests/unit/text.spec.js +++ b/tests/unit/text.spec.js @@ -192,6 +192,16 @@ Q expect(docData).toContainText({ text }); }); + + test('with null x coordinate', () => { + const docData = logData(document); + + document.text('text with null x', null, 50); + document.end(); + + expect(docData).toContainText({ text: 'text with null x' }); + }); + }); describe('text with structure parent links', () => { From b628d0d0ed3e785cd02f6943ed95ef6094fcb63b Mon Sep 17 00:00:00 2001 From: Zhicheng Chen Date: Tue, 17 Mar 2026 13:35:13 +0800 Subject: [PATCH 5/5] fix prettier --- tests/unit/text.spec.js | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/unit/text.spec.js b/tests/unit/text.spec.js index 26849264..69cdb3b4 100644 --- a/tests/unit/text.spec.js +++ b/tests/unit/text.spec.js @@ -201,7 +201,6 @@ Q expect(docData).toContainText({ text: 'text with null x' }); }); - }); describe('text with structure parent links', () => {