Skip to content

Commit 864931c

Browse files
committed
fix(input-number): avoid redundant calculation
1 parent 5c1e54d commit 864931c

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

packages/primeng/src/inputnumber/inputnumber.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export const INPUTNUMBER_VALUE_ACCESSOR: any = {
4040
useExisting: forwardRef(() => InputNumber),
4141
multi: true
4242
};
43+
4344
/**
4445
* InputNumber is an input component to provide numerical input.
4546
* @group Components
@@ -402,20 +403,23 @@ export class InputNumber extends BaseComponent implements OnInit, AfterContentIn
402403
* @group Props
403404
*/
404405
@Input({ transform: booleanAttribute }) autofocus: boolean | undefined;
406+
405407
/**
406408
* When present, it specifies that the element should be disabled.
407409
* @group Props
408410
*/
409411
@Input() get disabled(): boolean | undefined {
410412
return this._disabled;
411413
}
414+
412415
set disabled(disabled: boolean | undefined) {
413416
if (disabled) this.focused = false;
414417

415418
this._disabled = disabled;
416419

417420
if (this.timer) this.clearTimer();
418421
}
422+
419423
/**
420424
* Spans 100% width of the container when enabled.
421425
* @group Props
@@ -639,6 +643,7 @@ export class InputNumber extends BaseComponent implements OnInit, AfterContentIn
639643
const decimalChar = this.getDecimalChar();
640644
return new RegExp(`[${decimalChar}]`, 'g');
641645
}
646+
642647
getDecimalChar(): string {
643648
const formatter = new Intl.NumberFormat(this.locale, { ...this.getOptions(), useGrouping: false });
644649
return formatter
@@ -1516,7 +1521,7 @@ export class InputNumber extends BaseComponent implements OnInit, AfterContentIn
15161521
writeValue(value: any): void {
15171522
this.value = value ? Number(value) : value;
15181523
if (this.input) {
1519-
this.input.nativeElement.value = value ? Number(value) : value;
1524+
this.input.nativeElement.value = String(this.value);
15201525
}
15211526
this.cd.markForCheck();
15221527
}

0 commit comments

Comments
 (0)