diff --git a/src/platforms/web/compiler/directives/model.js b/src/platforms/web/compiler/directives/model.js index a42096109a..ba822dcbd6 100644 --- a/src/platforms/web/compiler/directives/model.js +++ b/src/platforms/web/compiler/directives/model.js @@ -146,8 +146,8 @@ function genDefaultModel ( } } - const { lazy, number, trim } = modifiers || {} - const needCompositionGuard = !lazy && type !== 'range' + const { lazy, number, trim, eager } = modifiers || {} + const needCompositionGuard = !lazy && type !== 'range' && !eager const event = lazy ? 'change' : type === 'range' diff --git a/test/unit/features/directives/model-text.spec.js b/test/unit/features/directives/model-text.spec.js index 7cf5167461..ff37aec63b 100644 --- a/test/unit/features/directives/model-text.spec.js +++ b/test/unit/features/directives/model-text.spec.js @@ -218,6 +218,26 @@ describe('Directive v-model text', () => { done() }) + it('.eager modifier', () => { + const vm = new Vue({ + data: { + test: 'foo' + }, + template: '' + }).$mount() + const input = vm.$el + triggerEvent(input, 'compositionstart') + input.value = 'baz' + // input before composition unlock should call set + triggerEvent(input, 'input') + expect(vm.test).toBe('baz') + // after composition unlock it should work + triggerEvent(input, 'compositionend') + input.value = 'bar' + triggerEvent(input, 'input') + expect(vm.test).toBe('bar') + }) + it('warn invalid tag', () => { new Vue({ data: {