Skip to content

Commit

Permalink
Avoid mutating objects in Color constructor (#603)
Browse files Browse the repository at this point in the history
  • Loading branch information
MysteryBlokHed authored Oct 24, 2024
1 parent f31f98d commit 07281ad
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/color.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 07281ad

Please sign in to comment.