From 5d0999ac375f477a9f2746ea746081d07ee60c64 Mon Sep 17 00:00:00 2001 From: Evan You Date: Wed, 12 Oct 2016 15:59:14 -0400 Subject: [PATCH] ensure v-model runtime metadata for all types --- src/platforms/web/compiler/directives/model.js | 12 ++++-------- src/platforms/web/runtime/directives/model.js | 5 ++++- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/platforms/web/compiler/directives/model.js b/src/platforms/web/compiler/directives/model.js index a59752e6..5f8639cd 100644 --- a/src/platforms/web/compiler/directives/model.js +++ b/src/platforms/web/compiler/directives/model.js @@ -25,14 +25,16 @@ export default function model ( } } if (tag === 'select') { - return genSelect(el, value) + genSelect(el, value) } else if (tag === 'input' && type === 'checkbox') { genCheckboxModel(el, value) } else if (tag === 'input' && type === 'radio') { genRadioModel(el, value) } else { - return genDefaultModel(el, value, modifiers) + genDefaultModel(el, value, modifiers) } + // ensure runtime directive metadata + return true } function genCheckboxModel (el: ASTElement, value: string) { @@ -128,10 +130,6 @@ function genDefaultModel ( } addProp(el, 'value', isNative ? `_s(${value})` : `(${value})`) addHandler(el, event, code, null, true) - if (needCompositionGuard) { - // need runtime directive code to help with composition events - return true - } } function genSelect (el: ASTElement, value: string) { @@ -143,8 +141,6 @@ function genSelect (el: ASTElement, value: string) { `.map(function(o){return "_value" in o ? o._value : o.value})` + (el.attrsMap.multiple == null ? '[0]' : '') addHandler(el, 'change', code, null, true) - // need runtime to help with possible dynamically generated options - return true } function checkOptionWarning (option: any): boolean { diff --git a/src/platforms/web/runtime/directives/model.js b/src/platforms/web/runtime/directives/model.js index 8c66721a..d3e72f0d 100644 --- a/src/platforms/web/runtime/directives/model.js +++ b/src/platforms/web/runtime/directives/model.js @@ -40,7 +40,10 @@ export default { if (isIE || isEdge) { setTimeout(cb, 0) } - } else if (vnode.tag === 'textarea' || el.type === 'text') { + } else if ( + (vnode.tag === 'textarea' || el.type === 'text') && + !binding.modifiers.lazy + ) { if (!isAndroid) { el.addEventListener('compositionstart', onCompositionStart) el.addEventListener('compositionend', onCompositionEnd)