Skip to content

Commit 62405aa

Browse files
committed
revert: fix(v-model): fix input listener with modifier blocking v-model update
This reverts commit 6f312d6 because the change is no longer needed after switching nextTick to use MessageChannel.
1 parent 405d8e9 commit 62405aa

File tree

2 files changed

+4
-29
lines changed

2 files changed

+4
-29
lines changed

src/core/vdom/helpers/update-listeners.js

+2-22
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,18 @@ import { cached, isUndef } from 'shared/util'
55

66
const normalizeEvent = cached((name: string): {
77
name: string,
8-
plain: boolean,
98
once: boolean,
109
capture: boolean,
11-
passive: boolean,
12-
handler?: Function
10+
passive: boolean
1311
} => {
1412
const passive = name.charAt(0) === '&'
1513
name = passive ? name.slice(1) : name
1614
const once = name.charAt(0) === '~' // Prefixed last, checked first
1715
name = once ? name.slice(1) : name
1816
const capture = name.charAt(0) === '!'
1917
name = capture ? name.slice(1) : name
20-
const plain = !(passive || once || capture)
2118
return {
2219
name,
23-
plain,
2420
once,
2521
capture,
2622
passive
@@ -44,11 +40,6 @@ export function createFnInvoker (fns: Function | Array<Function>): Function {
4440
return invoker
4541
}
4642

47-
// #6552
48-
function prioritizePlainEvents (a, b) {
49-
return a.plain ? -1 : b.plain ? 1 : 0
50-
}
51-
5243
export function updateListeners (
5344
on: Object,
5445
oldOn: Object,
@@ -57,13 +48,10 @@ export function updateListeners (
5748
vm: Component
5849
) {
5950
let name, cur, old, event
60-
const toAdd = []
61-
let hasModifier = false
6251
for (name in on) {
6352
cur = on[name]
6453
old = oldOn[name]
6554
event = normalizeEvent(name)
66-
if (!event.plain) hasModifier = true
6755
if (isUndef(cur)) {
6856
process.env.NODE_ENV !== 'production' && warn(
6957
`Invalid handler for event "${event.name}": got ` + String(cur),
@@ -73,20 +61,12 @@ export function updateListeners (
7361
if (isUndef(cur.fns)) {
7462
cur = on[name] = createFnInvoker(cur)
7563
}
76-
event.handler = cur
77-
toAdd.push(event)
64+
add(event.name, cur, event.once, event.capture, event.passive)
7865
} else if (cur !== old) {
7966
old.fns = cur
8067
on[name] = old
8168
}
8269
}
83-
if (toAdd.length) {
84-
if (hasModifier) toAdd.sort(prioritizePlainEvents)
85-
for (let i = 0; i < toAdd.length; i++) {
86-
const event = toAdd[i]
87-
add(event.name, event.handler, event.once, event.capture, event.passive)
88-
}
89-
}
9070
for (name in oldOn) {
9171
if (isUndef(on[name])) {
9272
event = normalizeEvent(name)

test/unit/features/directives/model-text.spec.js

+2-7
Original file line numberDiff line numberDiff line change
@@ -315,13 +315,8 @@ describe('Directive v-model text', () => {
315315
})
316316

317317
// #6552
318-
// Root cause: input listeners with modifiers are added as a separate
319-
// DOM listener. If a change is triggered inside this listener, an update
320-
// will happen before the second listener is fired! (obviously microtasks
321-
// can be processed in between DOM events on the same element)
322-
// This causes the domProps module to receive state that has not been
323-
// updated by v-model yet (because v-model's listener has not fired yet)
324-
// Solution: make sure to always fire v-model's listener first
318+
// This was original introduced due to the microtask between DOM events issue
319+
// but fixed after switching to MessageChannel.
325320
it('should not block input when another input listener with modifier is used', done => {
326321
const vm = new Vue({
327322
data: {

0 commit comments

Comments
 (0)