From 61e06c5758cf70031a5593f16b18df814c505085 Mon Sep 17 00:00:00 2001 From: GiftLanga Date: Fri, 26 Jul 2024 13:11:03 +0200 Subject: [PATCH] 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 --- src/cdk/coercion/number-property.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/cdk/coercion/number-property.ts b/src/cdk/coercion/number-property.ts index 2452ab2f15a8..50b5ff8d0841 100644 --- a/src/cdk/coercion/number-property.ts +++ b/src/cdk/coercion/number-property.ts @@ -16,7 +16,10 @@ export type NumberInput = string | number | null | undefined; export function coerceNumberProperty(value: any): number; export function coerceNumberProperty(value: any, fallback: D): number | D; export function coerceNumberProperty(value: any, fallbackValue = 0) { - return _isNumberValue(value) ? Number(value) : fallbackValue; + if (_isNumberValue(value)) { + return Number(value); + } + return arguments.length === 2 ? fallbackValue : 0; } /**