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:
Родитель
1a83dc36ce
Коммит
159eb0bdf4
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче