Handle nullish values in processBoxShadow and processFilter

Summary:
Viewconfig processors may still get called for nullish values I think. Most other processors explicitly handle these (but some don't??).

This returns an empty list, like on parse error, when we have a value, but the value is nullish.

Changelog: [Internal]

Reviewed By: joevilches

Differential Revision: D59933611

fbshipit-source-id: 3f1d89d21977bbe01a05e708aadf1a9451d88083
This commit is contained in:
Nick Gerleman
2024-07-18 17:17:16 -07:00
committed by Facebook GitHub Bot
parent cbdb4d78c0
commit 1315d65bf5
3 changed files with 11 additions and 4 deletions
@@ -24,9 +24,12 @@ export type ParsedBoxShadow = {
};
export default function processBoxShadow(
rawBoxShadows: $ReadOnlyArray<BoxShadowPrimitive> | string,
rawBoxShadows: ?($ReadOnlyArray<BoxShadowPrimitive> | string),
): Array<ParsedBoxShadow> {
const result: Array<ParsedBoxShadow> = [];
if (rawBoxShadows == null) {
return result;
}
const boxShadowList =
typeof rawBoxShadows === 'string'
@@ -36,9 +36,13 @@ type ParsedDropShadow = {
};
export default function processFilter(
filter: $ReadOnlyArray<FilterFunction> | string,
filter: ?($ReadOnlyArray<FilterFunction> | string),
): $ReadOnlyArray<ParsedFilter> {
let result: Array<ParsedFilter> = [];
if (filter == null) {
return result;
}
if (typeof filter === 'string') {
// matches on functions with args like "drop-shadow(1.5)"
const regex = /([\w-]+)\(([^)]+)\)/g;
@@ -8875,7 +8875,7 @@ exports[`public API should not change unintentionally Libraries/StyleSheet/proce
inset?: boolean,
};
declare export default function processBoxShadow(
rawBoxShadows: $ReadOnlyArray<BoxShadowPrimitive> | string
rawBoxShadows: ?($ReadOnlyArray<BoxShadowPrimitive> | string)
): Array<ParsedBoxShadow>;
"
`;
@@ -8916,7 +8916,7 @@ type ParsedDropShadow = {
color?: ColorValue,
};
declare export default function processFilter(
filter: $ReadOnlyArray<FilterFunction> | string
filter: ?($ReadOnlyArray<FilterFunction> | string)
): $ReadOnlyArray<ParsedFilter>;
"
`;