Skip to content

Commit e92b49f

Browse files
committed
fix: fail fast, do not try to apply logic when there's no mask
1 parent 62b42ea commit e92b49f

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

src/component.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,11 @@ export default {
3434
},
3535
computed: {
3636
config() {
37-
return {
37+
const config = !!this.mask && {
3838
mask: this.mask,
3939
tokens: this.tokens
4040
}
41+
return config
4142
},
4243
listeners() {
4344
const vm = this
@@ -50,7 +51,7 @@ export default {
5051
refresh(event) {
5152
let emittedValue = event ? event.target.value : this.value
5253
53-
if (!this.masked) {
54+
if (this.mask && !this.masked) {
5455
const maskerConfig = {
5556
mask: this.mask,
5657
tokens: this.tokens,

src/core.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,11 @@ export function getInputElement(el) {
4343
export function inputHandler(event) {
4444
const { target } = event
4545

46+
// do not run this function is there is no mask config
47+
if (!target[CONFIG_KEY].config) return false
4648
// we only need to run this method on native events (isTrusted == true for native events)
47-
// since we will be emitting our own input event we can stop propagation of the native event
4849
if (!event.isTrusted) return false
50+
// since we will be emitting our own input event we can stop propagation of the native event
4951
event.stopPropagation()
5052

5153
// gather some information from the input before masking

src/directive.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ export default {
2020
update: (el, { value, oldValue }) => {
2121
el = core.getInputElement(el)
2222

23-
if (value != oldValue) {
23+
if (value !== oldValue) {
2424
el[CONFIG_KEY].config = core.normalizeConfig(value)
2525
core.updateValue(el, { force: true })
26-
} else if (el.value !== el[CONFIG_KEY].oldValue) {
26+
} else {
2727
core.updateValue(el)
2828
}
2929
},

0 commit comments

Comments
 (0)