diff --git a/src/components/common.ts b/src/components/common.ts index a7257922e..46b0ae547 100644 --- a/src/components/common.ts +++ b/src/components/common.ts @@ -1,4 +1,4 @@ -import { VNodeDirective, VNode } from 'vue'; +import { VNode } from 'vue'; import { isCallable, debounce, identity } from '../utils'; import { modes, InteractionModeFactory } from '../modes'; import { ValidationResult, ValidationFlags, KnownKeys, ProviderInstance } from '../types'; @@ -153,7 +153,7 @@ export function addListeners(vm: ProviderInstance, node: VNode) { const value = findValue(node); // cache the input eventName. vm._inputEventName = vm._inputEventName || getInputEventName(node, findModel(node)); - onRenderUpdate(vm, value); + onRenderUpdate(vm, value && value.value); const { onInput, onBlur, onValidate } = createCommonHandlers(vm); addVNodeListener(node, vm._inputEventName, onInput); diff --git a/src/components/withValidation.ts b/src/components/withValidation.ts index 5452b049c..79b9e8041 100644 --- a/src/components/withValidation.ts +++ b/src/components/withValidation.ts @@ -37,7 +37,7 @@ export function withValidation(component: ComponentLike, mapProps: ValidationCon const model = findModel(this.$vnode); this._inputEventName = this._inputEventName || getInputEventName(this.$vnode, model); const value = findValue(this.$vnode); - onRenderUpdate(this, value); + onRenderUpdate(this, value && value.value); const { onInput, onBlur, onValidate } = createCommonHandlers(this); diff --git a/src/utils/vnode.ts b/src/utils/vnode.ts index 6b223dc1d..fdaf2fc02 100644 --- a/src/utils/vnode.ts +++ b/src/utils/vnode.ts @@ -44,21 +44,21 @@ export function findModel(vnode: VNode): VNodeDirective | undefined { return find(vnode.data.directives, d => d.name === 'model'); } -export function findValue(vnode: VNode): any | undefined { +export function findValue(vnode: VNode): { value: any } | undefined { const model = findModel(vnode); if (model) { - return model.value; + return { value: model.value }; } const config = findModelConfig(vnode); const prop = (config && config.prop) || 'value'; if (vnode.componentOptions && vnode.componentOptions.propsData && prop in vnode.componentOptions.propsData) { const propsDataWithValue = vnode.componentOptions.propsData as any; - return propsDataWithValue[prop]; + return { value: propsDataWithValue[prop] }; } if (vnode.data && vnode.data.domProps && 'value' in vnode.data.domProps) { - return vnode.data.domProps.value; + return { value: vnode.data.domProps.value }; } return undefined;