Skip to content

Commit

Permalink
refactor(demo-integrations): optimized using maxLength prop in TestInput
Browse files Browse the repository at this point in the history
  • Loading branch information
Stanslav Zaytsev committed Feb 26, 2024
1 parent 0a812da commit d40b080
Showing 1 changed file with 4 additions and 20 deletions.
24 changes: 4 additions & 20 deletions projects/demo-integrations/src/tests/component-testing/utils.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
import {
AfterViewInit,
Component,
ElementRef,
EventEmitter,
Input,
Output,
ViewChild,
} from '@angular/core';
import {Component, EventEmitter, Input, Output} from '@angular/core';
import {MaskitoDirective} from '@maskito/angular';
import {MaskitoOptions} from '@maskito/core';

Expand All @@ -16,16 +8,14 @@ import {MaskitoOptions} from '@maskito/core';
template: `
<input
#inputElemnt
[attr.maxlength]="maxLength"
[attr.value]="initialValue"
[maskito]="maskitoOptions"
(input)="input.emit($event)"
/>
`,
})
export class TestInput implements AfterViewInit {
@ViewChild('inputElemnt')
inputElement!: ElementRef;

export class TestInput {
@Input()
initialValue = '';

Expand All @@ -36,11 +26,5 @@ export class TestInput implements AfterViewInit {
input = new EventEmitter();

@Input()
maxLength?: number;

ngAfterViewInit(): void {
if (this.maxLength) {
this.inputElement.nativeElement.maxLength = this.maxLength;
}
}
maxLength?: number | null = null;
}

0 comments on commit d40b080

Please sign in to comment.