Skip to content

Commit 83f2737

Browse files
committed
Add backward-compatibility for events
1 parent 1561da0 commit 83f2737

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,13 @@ Read more on `vue-form-generator`'s [instruction page](https://icebob.gitbooks.i
117117

118118
### Events
119119

120-
| Property value | Arguments | Description |
121-
| -------------- | --------- | ----------- |
122-
| `input` | `String`, `Object` | Fires when the input changes with the argument is the object includes `{ number, isValid, country }` |
123-
| `validate` | `Object` | Fires when the correctness of the phone number changes (from `true` to `false` or vice-versa) and when the component is mounted `{ number, isValid, country }` |
124-
| `blur` | | Fires on blur event |
125-
| `space` | | Fires on keyup.space event |
126-
| `enter` | | Fires on keyup.enter event |
120+
| Property value | Arguments | Description | Notes |
121+
| -------------- | --------- | ----------- | ----- |
122+
| `input` | `String`, `Object` | Fires when the input changes with the argument is the object includes `{ number, isValid, country }` | `onInput` deprecated |
123+
| `validate` | `Object` | Fires when the correctness of the phone number changes (from `true` to `false` or vice-versa) and when the component is mounted `{ number, isValid, country }` | `onValidate` deprecated |
124+
| `blur` | | Fires on blur event | `onBlur` deprecated |
125+
| `space` | | Fires on keyup.space event | `onSpace` deprecated |
126+
| `enter` | | Fires on keyup.enter event | `onEnter` deprecated |
127127

128128
## Highlights & Credits
129129
- Vue app created by [vue-cli](https://github.com/vuejs/vue-cli).

src/vue-tel-input.vue

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ export default {
238238
this.phone = '+' + this.activeCountry.dialCode;
239239
}
240240
this.$emit('validate', this.response);
241+
this.$emit('onValidate', this.response); // Deprecated
241242
},
242243
created() {
243244
if (this.value) {
@@ -339,6 +340,7 @@ export default {
339340
// Otherwise format it
340341
this.phone = this.formattedResult;
341342
}
343+
this.$emit('onValidate', this.response); // Deprecated
342344
this.$emit('validate', this.response);
343345
},
344346
value() {
@@ -407,21 +409,26 @@ export default {
407409
this.phone = '+' + country.dialCode;
408410
}
409411
this.$emit('input', this.response.number, this.response);
412+
this.$emit('onInput', this.response); // Deprecated
410413
},
411414
onInput() {
412415
this.$refs.input.setCustomValidity(this.response.isValid ? '' : this.invalidMsg);
413416
// Returns response.number to assign it to v-model (if being used)
414417
// Returns full response for cases @input is used and parent wants to return the whole response.
415418
this.$emit('input', this.response.number, this.response);
419+
this.$emit('onInput', this.response); // Deprecated
416420
},
417421
onBlur() {
418422
this.$emit('blur');
423+
this.$emit('onBlur'); // Deprecated
419424
},
420425
onEnter() {
421426
this.$emit('enter');
427+
this.$emit('onEnter'); // Deprecated
422428
},
423429
onSpace() {
424430
this.$emit('space');
431+
this.$emit('onSpace'); // Deprecated
425432
},
426433
focus() {
427434
this.$refs.input.focus();

0 commit comments

Comments
 (0)