diff --git a/package-lock.json b/package-lock.json index 0996acf..625eebd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -196,6 +196,11 @@ "esprima": "^4.0.0" } }, + "lodash.isequal": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/lodash.isequal/-/lodash.isequal-4.5.0.tgz", + "integrity": "sha1-QVxEePK8wwEgwizhDtMib30+GOA=" + }, "lodash.set": { "version": "4.3.2", "resolved": "https://registry.npmjs.org/lodash.set/-/lodash.set-4.3.2.tgz", diff --git a/package.json b/package.json index ea27039..3707adf 100644 --- a/package.json +++ b/package.json @@ -28,6 +28,7 @@ }, "homepage": "https://github.com/titou10titou10/v-mask#readme", "dependencies": { + "lodash.isequal": "^4.5.0", "lodash.set": "^4.3.2" }, "devDependencies": { diff --git a/src/directive.ts b/src/directive.ts index 193b596..29eb68d 100644 --- a/src/directive.ts +++ b/src/directive.ts @@ -1,4 +1,5 @@ -import { set } from 'lodash'; +import set from 'lodash.set'; +import isEqual from 'lodash.isequal'; import masker from './masker'; import predefinedMasks from './predefined'; @@ -111,7 +112,8 @@ function componentUpdated(el, binding, vnode, oldVnode) { // Prevent firing endless events const data = vnode.data.props || vnode.data.model; const oldData = oldVnode.data.props || oldVnode.data.model; - if (data && data.value === oldData.value) { return; } + if (data && data.value === oldData.value && + isEqual(binding.value, binding.oldValue)) { return; } const realEl = getInput(el); realEl.value = data ? data.value : realEl.value;