Skip to content

Commit 147a862

Browse files
committed
updated events
1 parent 5c56199 commit 147a862

File tree

2 files changed

+7
-22
lines changed

2 files changed

+7
-22
lines changed

src/component.vue

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,7 @@ export default Vue.extend({
3333
type: [Number, String],
3434
default: options.nullValue
3535
},
36-
masked: {
37-
type: Boolean,
38-
default: false
39-
},
36+
masked: Boolean,
4037
reverseFill: {
4138
type: Boolean,
4239
default: options.reverseFill

src/core.ts

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -56,20 +56,8 @@ export function setConfig(el: HTMLInputElement, config: any) {
5656
* Creates a CustomEvent('input') with detail = { facade: true }
5757
* used as a way to identify our own input event
5858
*/
59-
export function FacadeInputEvent() {
60-
return new CustomEvent('input', {
61-
bubbles: true,
62-
cancelable: true,
63-
detail: { facade: true }
64-
})
65-
}
66-
67-
/**
68-
* Creates a CustomEvent('change') with detail = { facade: true }
69-
* used as a way to identify our own change event
70-
*/
71-
export function FacadeChangeEvent() {
72-
return new CustomEvent('change', {
59+
export function InputEvent(type: string) {
60+
return new CustomEvent(type, {
7361
bubbles: true,
7462
cancelable: true,
7563
detail: { facade: true }
@@ -141,7 +129,7 @@ export function updateValue(el: CustomInputElement, vnode: VNode | null, { emit
141129

142130
// this part needs to be outside the above IF statement for vuetify in firefox
143131
// drawback is that we endup with two's input events in firefox
144-
return emit && el.dispatchEvent(FacadeInputEvent())
132+
return emit && el.dispatchEvent(InputEvent('input'))
145133
}
146134
}
147135

@@ -182,7 +170,7 @@ export function inputHandler(event: CustomInputEvent) {
182170

183171
if (oldValue !== target.value) {
184172
target.oldValue = masked
185-
target.dispatchEvent(FacadeInputEvent())
173+
target.dispatchEvent(InputEvent('input'))
186174
}
187175
}
188176

@@ -199,11 +187,11 @@ export function blurHandler(event: Event) {
199187

200188
const { oldValue, masked } = target
201189

202-
updateValue(target, null, { force: true, emit: true, clean: true })
190+
updateValue(target, null, { force: true, emit: false, clean: true })
203191

204192
if (oldValue !== target.value) {
205193
target.oldValue = masked
206-
target.dispatchEvent(FacadeChangeEvent())
194+
target.dispatchEvent(InputEvent('change'))
207195
}
208196
}
209197

0 commit comments

Comments
 (0)