Skip to content

Commit

Permalink
refactor update options and value
Browse files Browse the repository at this point in the history
  • Loading branch information
Kryazhev Alexey committed Sep 19, 2017
1 parent fa7fc37 commit d13cbb9
Show file tree
Hide file tree
Showing 12 changed files with 36 additions and 151 deletions.
76 changes: 10 additions & 66 deletions dist/imask.es.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/imask.es.js.map

Large diffs are not rendered by default.

76 changes: 10 additions & 66 deletions dist/imask.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/imask.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/imask.min.es.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/imask.min.es.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/imask.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/imask.min.js.map

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions src/controls/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ class InputMask {

get mask () { return this.masked.mask; }
set mask (mask) {
const unmasked = this.masked ? this.masked.unmaskedValue : null;
let opts = {mask};
if (typeof mask === typeof this.masked.mask) {
this.masked.mask = mask;
opts = this.masked;
return;
}
this.masked = createMask(opts);

const unmasked = this.masked ? this.masked.unmaskedValue : null;
this.masked = createMask({mask});
if (unmasked != null) this.masked.unmaskedValue = unmasked;
}

Expand Down
1 change: 0 additions & 1 deletion src/imask.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'core-js/fn/array/find';
import 'core-js/fn/object/keys';
import 'core-js/fn/object/create';
import 'core-js/fn/string/repeat';
import 'core-js/fn/string/pad-start';
import 'core-js/fn/string/pad-end';
Expand Down
8 changes: 4 additions & 4 deletions src/masked/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class Masked {
set value (value) {
this.reset();
this.appendWithTail(value);
this.commit();
}

get unmaskedValue () {
Expand All @@ -50,6 +51,7 @@ class Masked {
this.reset();
this._append(value);
this.appendWithTail("");
this.commit();
}

get isComplete () {
Expand Down Expand Up @@ -138,10 +140,8 @@ class Masked {

const ret = fn();

if (unmasked != null) {
this.unmaskedValue = unmasked;
this.commit();
}
if (unmasked != null) this.unmaskedValue = unmasked;

delete this._refreshing;
return ret;
}
Expand Down
6 changes: 2 additions & 4 deletions src/masked/factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ import {isString} from '../core/utils';

export default
function createMask (opts) {
const _opts = opts;
// clone
opts = Object.create(opts);
Object.assign(opts, _opts);
opts = Object.assign({}, opts); // clone

const mask = opts.mask;

if (mask instanceof IMask.Masked) {
Expand Down

0 comments on commit d13cbb9

Please sign in to comment.