From ca171ae194d307700d98d4447f29804ee37e920b Mon Sep 17 00:00:00 2001 From: Shachar <34343793+ShaMan123@users.noreply.github.com> Date: Mon, 6 May 2024 12:27:54 +0300 Subject: [PATCH] fix(Polyline): safeguard points arg from options (#9855) --- CHANGELOG.md | 1 + src/shapes/Polyline.spec.ts | 8 ++++++++ src/shapes/Polyline.ts | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 499011a1e1b..86b9228c91a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## [next] +- fix(Polyline): safeguard points arg from options [#9855](https://github.com/fabricjs/fabric.js/pull/9855) - feat(IText): Adjust cursor blinking for better feedback [#9823](https://github.com/fabricjs/fabric.js/pull/9823) - feat(FabricObject): pass `e` to `shouldStartDragging` [#9843](https://github.com/fabricjs/fabric.js/pull/9843) - fix(Canvas): mouse move before event data [#9849](https://github.com/fabricjs/fabric.js/pull/9849) diff --git a/src/shapes/Polyline.spec.ts b/src/shapes/Polyline.spec.ts index 2e1149d5cfe..5feb1c8ad7a 100644 --- a/src/shapes/Polyline.spec.ts +++ b/src/shapes/Polyline.spec.ts @@ -106,4 +106,12 @@ describe('Polyline', () => { }); }); }); + + it('should safeguard passing points in options', () => { + expect(new Polyline(points, { points: [{ x: 1, y: 1 }] })).toEqual( + expect.objectContaining({ + points: points, + }) + ); + }); }); diff --git a/src/shapes/Polyline.ts b/src/shapes/Polyline.ts index f14548cdfef..bcede176566 100644 --- a/src/shapes/Polyline.ts +++ b/src/shapes/Polyline.ts @@ -108,7 +108,7 @@ export class Polyline< * }); */ constructor(points: XY[] = [], options: Props = {} as Props) { - super({ points, ...options }); + super({ ...options, points }); const { left, top } = options; this.initialized = true; this.setBoundingBox(true);