Skip to content

Commit

Permalink
refactor(igxMask): rename parseMaskOnInit to parseMask
Browse files Browse the repository at this point in the history
- remove old parseMask function
  • Loading branch information
jackofdiamond5 committed Feb 7, 2020
1 parent 0b6c2a1 commit df6a6c9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,7 @@ export class MaskParsingService {
return this._cursor;
}

public parseMask(maskOptions): string {
let outputVal = '';
const mask: string = maskOptions.format;
const literals: Map<number, string> = this.getMaskLiterals(mask);

for (const maskSym of mask) {
outputVal += maskOptions.promptChar;
}

literals.forEach((val: string, key: number) => {
outputVal = this.replaceCharAt(outputVal, key, val);
});

return outputVal;
}

public parseMaskOnInit(inputVal, maskOptions): string {
public parseMask(inputVal, maskOptions): string {
let outputVal = '';
let value = '';
const mask: string = maskOptions.format;
Expand Down Expand Up @@ -109,7 +93,7 @@ export class MaskParsingService {
if (hasDeleteAction) {
if (inputText === '') {
this._cursor = 0;
return this.parseMaskOnInit(inputText, maskOptions);
return this.parseMask(inputText, maskOptions);
}
let i = 0;
this._cursor = ++cursor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ export class IgxMaskDirective implements OnInit, AfterViewChecked, ControlValueA
}
this.inputValue = this.focusedValuePipe.transform(value);
} else {
this.inputValue = this.maskParser.parseMaskOnInit(this.inputValue, this.maskOptions);
this.inputValue = this.maskParser.parseMask(this.inputValue, this.maskOptions);
}
}

Expand All @@ -210,7 +210,7 @@ export class IgxMaskDirective implements OnInit, AfterViewChecked, ControlValueA
public onBlur(value): void {
if (this.displayValuePipe) {
this.inputValue = this.displayValuePipe.transform(value);
} else if (value === this.maskParser.parseMask(this.maskOptions)) {
} else if (value === this.maskParser.parseMask(null, this.maskOptions)) {
this.inputValue = '';
}
this._onTouchedCallback();
Expand All @@ -226,7 +226,7 @@ export class IgxMaskDirective implements OnInit, AfterViewChecked, ControlValueA
this.maskOptions.promptChar = this.promptChar.substring(0, 1);
}

this.inputValue = value ? this.maskParser.parseMaskOnInit(value, this.maskOptions) : '';
this.inputValue = value ? this.maskParser.parseMask(value, this.maskOptions) : '';
if (this.displayValuePipe) {
this.inputValue = this.displayValuePipe.transform(this.inputValue);
}
Expand Down

0 comments on commit df6a6c9

Please sign in to comment.