Skip to content

Commit 2c76917

Browse files
GiftLangacrisbeto
authored andcommitted
fix(cdk/coercion): Return undefined when the fallback value is undefined (#29491)
Returns undefined when the fallback argument is undefined for cases where the value is not a number Fixes #29425 (cherry picked from commit c9078d1)
1 parent caa4bc5 commit 2c76917

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/cdk/coercion/number-property.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ export type NumberInput = string | number | null | undefined;
1616
export function coerceNumberProperty(value: any): number;
1717
export function coerceNumberProperty<D>(value: any, fallback: D): number | D;
1818
export function coerceNumberProperty(value: any, fallbackValue = 0) {
19-
return _isNumberValue(value) ? Number(value) : fallbackValue;
19+
if (_isNumberValue(value)) {
20+
return Number(value);
21+
}
22+
return arguments.length === 2 ? fallbackValue : 0;
2023
}
2124

2225
/**

0 commit comments

Comments
 (0)