Skip to content
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.js objects cannot be wrapped in a Proxy (and thus, cannot be used with Vue or other Proxy-based libraries) #305

Closed
LeaVerou opened this issue Apr 28, 2023 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@LeaVerou
Copy link
Member

LeaVerou commented Apr 28, 2023

Due to using private properties, every time a Color instance is wrapped in a Proxy, errors are just around the corner.

For context, see:

We only use a single private property: #space, and it's primarily to ensure color space is immutable. We can just use Object.defineProperty() instead and be done with it.

Edit: There is actually a bunch more privates in space.js but nothing too hard to refactor out.

@LeaVerou LeaVerou added the bug Something isn't working label Apr 28, 2023
@LeaVerou LeaVerou self-assigned this Apr 28, 2023
@LeaVerou LeaVerou changed the title Color.js OO API cannot be wrapped in a Proxy (and thus, cannot be used with Vue) Color.js OO API cannot be wrapped in a Proxy (and thus, cannot be used with Vue or other Proxy-based libraries) Apr 28, 2023
@LeaVerou LeaVerou changed the title Color.js OO API cannot be wrapped in a Proxy (and thus, cannot be used with Vue or other Proxy-based libraries) Color.js objects cannot be wrapped in a Proxy (and thus, cannot be used with Vue or other Proxy-based libraries) Apr 28, 2023
@LeaVerou
Copy link
Member Author

It is actually worse than I thought: this even affects plain color objects, as they still use ColorSpace objects.

It is unclear if there is a way to definitively check color space equality without using object equality. In #306 I fall back to string comparison of ids, but that's …not great.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant