-
-
Notifications
You must be signed in to change notification settings - Fork 86
2 fixes for type="custom" ColorSpaces #628
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
Conversation
Breaks the loop when the format is found. Allows format not to define a parse() method.
✅ Deploy Preview for colorjs ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Co-authored-by: Lea Verou <lea@verou.me>
Co-authored-by: Lea Verou <lea@verou.me>
I added a suggestion for a more clear name, since both are loops.
Why was it causing issues with custom formats? If changing the order fixes these issues, it sounds like a fix by coincidence, not a robust fix.
Rather than encoding format-related logic at the point of usage, it seems better to include a
We can't know what plugins people may have, and it doesn't seem like a good idea to couple this kind of information there unless we can generate it (but then cache invalidation becomes a concern). |
I committed your suggestions. It's still failing the lint tests. I don't think it has anything to do with these 3 commits.
It has been a while since then... I know I had to do a lot of fiddling around to get my color space to work. I should have been more specific in the original PR, from whence that text originates.
I think that's above my pay grade at this time. |
Yeah don't worry about the lint tests right now.
It's literally just adding this in the Format class: parse() {
return null;
} You'd need to test whether it works though. |
Base class returns null, which is falsy.
I created |
After stepping through the different versions of this, there is nothing my current code that depends on this change. I have been importing If there was or is another issue, maybe a description of it is buried in the original discussion #593. Otherwise I can understand if you'd prefer to back out the changes to parse.js and let this PR be about the default |
It occurs to me that if you want to preserve the behavior of using the last match, then it would be best to iterate over the registry in reverse. All the user color spaces are at the end of the list, and |
Two fixes that come out of this discussion: #593
break loop;
This was not only causing unnecessary iterations of the loop, it was causing issues with user ColorSpaces with{type:"custom"}
.?.
in this line:so that "custom" ColorSpace formats don't require a
parse
property. The discussion linked above creates a custom ColorSpace with a default format that has a custom serialize() property/function, but doesn't need a parse property. The current code requires it to have a dummy parse() property/function that returns falsy. This change removes that requirement and prevents the throwing of unnecessary errors.It is worth noting that there is only one built-in space with custom formats: sRGB, and it's the near the end of
ColorSpace.all
. Is there a need to iterate over any other color spaces?