Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit df01719

Browse filesBrowse files
committed
force v-model sync on change instead of blur (fix vuejs#2400)
1 parent 59868bb commit df01719
Copy full SHA for df01719

File tree

Expand file treeCollapse file tree

2 files changed

+6
-7
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+6
-7
lines changed

‎src/directives/public/model/text.js

Copy file name to clipboardExpand all lines: src/directives/public/model/text.js
+2-6Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,6 @@ export default {
5353
})
5454
this.on('blur', function () {
5555
self.focused = false
56-
// do not sync value after fragment removal (#2017)
57-
if (!self._frag || self._frag.inserted) {
58-
self.rawListener()
59-
}
6056
})
6157
}
6258

@@ -96,12 +92,12 @@ export default {
9692
this.hasjQuery = typeof jQuery === 'function'
9793
if (this.hasjQuery) {
9894
const method = jQuery.fn.on ? 'on' : 'bind'
99-
jQuery(el)[method]('change', this.listener)
95+
jQuery(el)[method]('change', this.rawListener)
10096
if (!lazy) {
10197
jQuery(el)[method]('input', this.listener)
10298
}
10399
} else {
104-
this.on('change', this.listener)
100+
this.on('change', this.rawListener)
105101
if (!lazy) {
106102
this.on('input', this.listener)
107103
}

‎test/unit/specs/directives/public/model_spec.js

Copy file name to clipboardExpand all lines: test/unit/specs/directives/public/model_spec.js
+4-1Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,7 @@ describe('v-model', function () {
499499
_.nextTick(function () {
500500
expect(el.firstChild.value).toBe('cc')
501501
expect(vm.test).toBe('cc')
502+
trigger(el.firstChild, 'change')
502503
trigger(el.firstChild, 'blur')
503504
_.nextTick(function () {
504505
expect(el.firstChild.value).toBe('CC')
@@ -529,6 +530,7 @@ describe('v-model', function () {
529530
_.nextTick(function () {
530531
expect(el.firstChild.value).toBe('cc')
531532
expect(vm.test).toBe('CC')
533+
trigger(el.firstChild, 'change')
532534
trigger(el.firstChild, 'blur')
533535
_.nextTick(function () {
534536
expect(el.firstChild.value).toBe('CC')
@@ -712,7 +714,8 @@ describe('v-model', function () {
712714
expect(vm.test).toBe('d')
713715
setTimeout(function () {
714716
el.firstChild.value = 'e'
715-
// blur should trigger change instantly without debounce
717+
// change should trigger change instantly without debounce
718+
trigger(el.firstChild, 'change')
716719
trigger(el.firstChild, 'blur')
717720
_.nextTick(function () {
718721
expect(spy.calls.count()).toBe(2)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.