[fix] Only stringify numeric aspectRatio

Close #2561
This commit is contained in:
ramiel
2023-07-18 16:40:43 +03:00
committed by Nicolas Gallagher
parent 213b616b3c
commit 617b438530
3 changed files with 8 additions and 2 deletions

View File

@@ -99,6 +99,12 @@ describe('StyleSheet/preprocess', () => {
expect(preprocess({ aspectRatio: 9 / 16 })).toEqual({
aspectRatio: '0.5625'
});
expect(preprocess({ aspectRatio: '0.5' })).toEqual({
aspectRatio: '0.5'
});
expect(preprocess({ aspectRatio: undefined })).toEqual({});
});
test('fontVariant', () => {

View File

@@ -182,7 +182,7 @@ export const preprocess = <T: {| [key: string]: any |}>(
continue;
}
if (prop === 'aspectRatio') {
if (prop === 'aspectRatio' && typeof value === 'number') {
nextStyle[prop] = value.toString();
} else if (prop === 'fontVariant') {
if (Array.isArray(value) && value.length > 0) {

View File

@@ -188,7 +188,7 @@ export type LayoutStyles = {|
| 'flex-start'
| 'stretch'
),
aspectRatio?: ?number,
aspectRatio?: ?NumberOrString,
backfaceVisibility?: ?VisiblilityValue,
borderWidth?: ?DimensionValue,
borderBlockWidth?: ?DimensionValue,