From 025ae5e1511a8b619e932e6e44a73d883e83ad75 Mon Sep 17 00:00:00 2001 From: Adam Thompson-Sharpe Date: Tue, 22 Oct 2024 23:22:58 -0400 Subject: [PATCH] Avoid mutating objects in Color constructor --- src/color.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/color.js b/src/color.js index d3caee32a..c60cfe586 100644 --- a/src/color.js +++ b/src/color.js @@ -47,6 +47,10 @@ export default class Color { if (args.length === 1) { let parseMeta = {}; + // Clone simple objects to avoid mutating original in getColor + if (typeof args[0] === "object" && Object.getPrototypeOf(args[0]).constructor === Object) { + args[0] = { ...args[0] }; + } color = getColor(args[0], {parseMeta}); if (parseMeta.format) {