Skip to content
This repository was archived by the owner on Oct 17, 2022. It is now read-only.

Commit cd1152b

Browse files
committed
Fix blur event, #13
* v-on="listeners" was buggy for reasons
1 parent bc8b569 commit cd1152b

File tree

2 files changed

+6
-16
lines changed

2 files changed

+6
-16
lines changed

examples/App.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@
120120
cardNumber: null,
121121
phoneNumber: null,
122122
date: null,
123-
number: null,
123+
number: 1234567,
124124
},
125125
// https://github.com/nosir/cleave.js/blob/master/doc/options.md
126126
options: {

src/component.vue

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
<template>
2-
<input :type="type" v-bind="$attrs" v-on="inputListeners">
2+
<input :type="type" @blur="onBlur">
33
</template>
44

55
<script>
66
import Cleave from 'cleave.js'
77
88
export default {
99
name: 'cleave',
10-
inheritAttrs: false,
1110
props: {
1211
value: {
1312
default: null,
@@ -26,6 +25,7 @@
2625
type: Boolean,
2726
default: true
2827
},
28+
// Input type, for example `tel`
2929
type: {
3030
type: String,
3131
default: 'text'
@@ -74,6 +74,9 @@
7474
this.onValueChangedFn.call(this, event)
7575
}
7676
},
77+
onBlur(event) {
78+
this.$emit('blur', this.value)
79+
}
7780
},
7881
watch: {
7982
/**
@@ -107,19 +110,6 @@
107110
this.cleave.setRawValue(newValue);
108111
}
109112
},
110-
computed: {
111-
inputListeners() {
112-
return Object.assign({},
113-
// Add all the listeners from the parent
114-
this.$listeners,
115-
{
116-
blur: (event) => {
117-
this.$emit('blur', this.value)
118-
}
119-
}
120-
)
121-
}
122-
},
123113
/**
124114
* Free up memory
125115
*/

0 commit comments

Comments
 (0)