Skip to content

Commit

Permalink
fix(cdk/coercion): Return undefined when the fallback value is undefined
Browse files Browse the repository at this point in the history
Returns undefined when the fallback argument is undefined
for cases where the value is not a number

Fixes #29425
  • Loading branch information
GiftLanga committed Jul 26, 2024
1 parent c4f033c commit 9e14140
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/cdk/coercion/number-property.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export type NumberInput = string | number | null | undefined;
export function coerceNumberProperty(value: any): number;
export function coerceNumberProperty<D>(value: any, fallback: D): number | D;
export function coerceNumberProperty(value: any, fallbackValue = 0) {
return _isNumberValue(value) ? Number(value) : fallbackValue;
return _isNumberValue(value) ? Number(value) : arguments.length === 2 ? fallbackValue : 0;
}

/**
Expand Down

0 comments on commit 9e14140

Please sign in to comment.