From 94d019ee3c8ff8439aeebc2380246c3ea01ed058 Mon Sep 17 00:00:00 2001 From: Valentin Date: Thu, 9 May 2019 15:42:28 +0300 Subject: [PATCH] Added tests for 0 value width/height wrong path scaling --- spec/spec/path.js | 9 +++++++++ src/types/PathArray.js | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/spec/spec/path.js b/spec/spec/path.js index 9a78b25..28780c9 100644 --- a/spec/spec/path.js +++ b/spec/spec/path.js @@ -164,6 +164,15 @@ describe('Path', function() { expect(path.height()).toBe(525) expect(path.width() / path.height()).toBeCloseTo(box.width / box.height) }) + it('doesn\'t scale width/height when their value is 0', function() { + path = draw.path('M0 0L0 100') + path.size(500, 500) + expect(path.attr('d')).toBe('M0 0L0 500 ') + + path = draw.path('M0 0L100 0') + path.size(500, 500) + expect(path.attr('d')).toBe('M0 0L500 0 ') + }) }) describe('scale()', function() { diff --git a/src/types/PathArray.js b/src/types/PathArray.js index affd853..56df5b6 100644 --- a/src/types/PathArray.js +++ b/src/types/PathArray.js @@ -186,7 +186,7 @@ extend(PathArray, { // transformations on the respective axis box.width = box.width === 0 ? 1 : box.width box.height = box.height === 0 ? 1 : box.height - + // recalculate position of all points according to new size for (i = this.length - 1; i >= 0; i--) { l = this[i][0] -- 2.39.5