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 diff --git a/lib/mixins/text.js b/lib/mixins/text.js index 82906531..f83d8ba7 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(result.rotation ?? 0) % 360; if (result.rotation < 0) result.rotation += 360; return result; diff --git a/tests/unit/text.spec.js b/tests/unit/text.spec.js index 8d6cc7e7..69cdb3b4 100644 --- a/tests/unit/text.spec.js +++ b/tests/unit/text.spec.js @@ -192,6 +192,15 @@ 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', () => {