Skip to content

fix(core): Color.isValid returned true for null/undefined #10040

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

Merged
merged 3 commits into from
Nov 13, 2022

Conversation

CatchABus
Copy link
Contributor

@CatchABus CatchABus commented Sep 25, 2022

PR Checklist

What is the current behavior?

For a strange reason, method Color.isValid was designed to consider null and undefined values to be valid colors.

What is the new behavior?

Method Color.isValid will return false if given value is null or undefined.
Old check was removed completely as isString check will handle the possibility of a nullish value.

@cla-bot cla-bot bot added the cla: yes label Sep 25, 2022
@edusperoni
Copy link
Contributor

This might introduce an issue on equality comparers where a null color can be expected. I don't know where specifically, but I remember there was one case this might be expected. I believe this fix is correct, but we might want to check where this is used and may need to add special conditions for null colors

@CatchABus
Copy link
Contributor Author

This might introduce an issue on equality comparers where a null color can be expected. I don't know where specifically, but I remember there was one case this might be expected. I believe this fix is correct, but we might want to check where this is used and may need to add special conditions for null colors

Afaik, we use Color.equals for equality comparers. I did a quick search inside core package and it seems there is only 1 place we use it right now: https://github.com/NativeScript/NativeScript/blob/main/packages/core/ui/animation/animation-common.ts#L160

@NathanWalker NathanWalker added this to the 8.4 milestone Sep 27, 2022
@NathanWalker NathanWalker merged commit 9091e43 into NativeScript:main Nov 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants