Normalize platform colors early

Summary:
Changelog: [Internal]

Fixes `normalizeColor` to always return the normalized color. Previously, when normalization was delegated to `normalizeColorObject`, we would return the *original* color object, which is a bug.

Reviewed By: javache

Differential Revision: D34048595

fbshipit-source-id: 083cbe36be2311ea9cffe8ef61e6a986840aec71
This commit is contained in:
Moti Zilberman 2022-02-10 04:55:48 -08:00 коммит произвёл Facebook GitHub Bot
Родитель 1a83dc36ce
Коммит 159eb0bdf4
2 изменённых файлов: 11 добавлений и 6 удалений

Просмотреть файл

@ -37,7 +37,12 @@ describe('iOS', () => {
it('should normalize iOS Dynamic colors with named colors', () => {
const color = DynamicColorIOS({light: 'black', dark: 'white'});
const normalizedColor = normalizeColor(color);
const expectedColor = {dynamic: {light: 'black', dark: 'white'}};
const expectedColor = {
dynamic: {
light: normalizeColor('black'),
dark: normalizeColor('white'),
},
};
expect(normalizedColor).toEqual(expectedColor);
});
@ -51,10 +56,10 @@ describe('iOS', () => {
const normalizedColor = normalizeColor(color);
const expectedColor = {
dynamic: {
light: 'black',
dark: 'white',
highContrastLight: 'red',
highContrastDark: 'blue',
light: normalizeColor('black'),
dark: normalizeColor('white'),
highContrastLight: normalizeColor('red'),
highContrastDark: normalizeColor('blue'),
},
};
expect(normalizedColor).toEqual(expectedColor);

Просмотреть файл

@ -22,7 +22,7 @@ function normalizeColor(
const {normalizeColorObject} = require('./PlatformColorValueTypes');
const normalizedColor = normalizeColorObject(color);
if (normalizedColor != null) {
return color;
return normalizedColor;
}
}