-
-
Notifications
You must be signed in to change notification settings - Fork 83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Color constructor should handle argument as immutable #590
Comments
Ah yeah, it should copy the object, at least when it needs to be modified. Especially since perf is not a huge consideration with the OOP API. |
It looks like Lines 40 to 43 in 45ba172
This could be solved by calling Lines 48 to 56 in 45ba172
i.e.: color = getColor(structuredClone(args[0]), {parseMeta}); |
Not sure we need |
|
We can detect if something is a plan object and branch accordingly. Not sure if that would be the best course of action, just throwing it out there as an option. |
That seems like the most performant thing to do—although I don't actually know the best way to check if something is a plain object in JS. Maybe |
This is how I did it in the past: https://github.com/mavoweb/mavo/blob/main/src/util.js#L61 ( |
Based on that, I think something like |
Hey there!
I was surprised to figure out that a call to
new Color({ ... })
modifies my provided object by adding thespace
to it.I guess this is a 🪲
Best
Benny
The text was updated successfully, but these errors were encountered: