Skip to content

Commit 61e06c5

Browse files
committed
fix(cdk/coercion): Return undefined when the fallback value is undefined
Returns undefined when the fallback argument is undefined for cases where the value is not a number Fixes #29425
1 parent c4f033c commit 61e06c5

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)