Skip to content

Commit bbb0fbd

Browse files
committed
updated core function
1 parent bfef9af commit bbb0fbd

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

src/core.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export function cloneDeep(data: object) {
4848
* Creates a CustomEvent with detail = { facade: true }
4949
* used as a way to identify our own event
5050
*/
51-
export function FacadeEvent(event: string) {
51+
export function InputEvent(event: string) {
5252
return new CustomEvent(event, {
5353
bubbles: true,
5454
cancelable: true,
@@ -111,7 +111,6 @@ export function updateValue(el: CustomInputElement, vnode: VNode | null, { emit
111111
}
112112
}
113113

114-
el.oldValue = masked
115114
el.masked = masked
116115
el.unmaskedValue = unmasked
117116

@@ -122,7 +121,7 @@ export function updateValue(el: CustomInputElement, vnode: VNode | null, { emit
122121

123122
// this part needs to be outside the above IF statement for vuetify in firefox
124123
// drawback is that we endup with two's input events in firefox
125-
return emit && el.dispatchEvent(FacadeEvent('input'))
124+
return emit && el.dispatchEvent(InputEvent('input'))
126125
}
127126
}
128127

@@ -139,12 +138,11 @@ export function inputHandler(event: CustomInputEvent) {
139138
return false
140139
}
141140

142-
const { oldValue, options, masked } = target
143-
144141
// since we will be emitting our own custom input event
145142
// we can stop propagation of this native event
146143
event.stopPropagation()
147144

145+
const { oldValue, options } = target
148146
let positionFromEnd = target.value.length
149147
if (target.selectionEnd) {
150148
positionFromEnd = target.value.length - target.selectionEnd
@@ -163,8 +161,7 @@ export function inputHandler(event: CustomInputEvent) {
163161
updateCursor(target, positionFromEnd)
164162

165163
if (oldValue !== target.value) {
166-
target.oldValue = masked
167-
target.dispatchEvent(FacadeEvent('input'))
164+
target.dispatchEvent(InputEvent('input'))
168165
}
169166
}
170167

@@ -181,11 +178,11 @@ export function blurHandler(event: Event) {
181178

182179
const { oldValue, masked } = target
183180

184-
updateValue(target, null, { emit: false, force: true, clean: true })
181+
updateValue(target, null, { force: true, emit: false, clean: true })
185182

186183
if (oldValue !== target.value) {
187184
target.oldValue = masked
188-
target.dispatchEvent(FacadeEvent('change'))
185+
target.dispatchEvent(InputEvent('change'))
189186
}
190187
}
191188

0 commit comments

Comments
 (0)