Skip to content

Commit

Permalink
fix: improve early escape detection after finding model closes #2378
Browse files Browse the repository at this point in the history
  • Loading branch information
logaretm committed Sep 26, 2019
1 parent b33bbdd commit 029d0e7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions 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';
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/components/withValidation.ts
Expand Up @@ -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);

Expand Down
8 changes: 4 additions & 4 deletions src/utils/vnode.ts
Expand Up @@ -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;
Expand Down

0 comments on commit 029d0e7

Please sign in to comment.