Skip to content

Commit

Permalink
Fix a bug when trying to set the mask value when overwrite option is …
Browse files Browse the repository at this point in the history
…true (#172)

* Fix a bug when trying to set the mask value when overwrite option is true

* _appendChar method only must receive TailDetails or null
  • Loading branch information
AriasBros authored and uNmAnNeR committed May 4, 2019
1 parent fd08bc1 commit d421b68
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/imask/src/masked/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ class Masked<MaskType> {
// $FlowFixMe no ideas
append (str: string, flags?: AppendFlags, tail?: string | TailDetails): ChangeDetails {
const details = new ChangeDetails();
const checkTail = tail && (isString(tail) ? new ContinuousTailDetails(String(tail)) : tail);
const checkTail = isString(tail) ? new ContinuousTailDetails(String(tail)) : tail;

for (let ci=0; ci<str.length; ++ci) {
details.aggregate(this._appendChar(str[ci], flags, checkTail));
Expand Down
13 changes: 13 additions & 0 deletions packages/imask/test/controls/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,17 @@ describe('InputMask', function () {
assert.strictEqual(imask.unmaskedValue, str);
});
});

describe('#update value when overwrite option is true', function () {
it('should update mask and set new value', function () {
imask.updateOptions({
mask: Number,
overwrite: true
});

const value = "100";
imask.value = value;
assert.strictEqual(imask.value, value);
});
});
});

0 comments on commit d421b68

Please sign in to comment.