feat(runtime-dom): v-model directive runtime
This commit is contained in:
@@ -12,7 +12,7 @@ return applyDirectives(h(comp), [
|
||||
*/
|
||||
|
||||
import { VNode, cloneVNode } from './vnode'
|
||||
import { extend, isArray, isFunction } from '@vue/shared'
|
||||
import { extend, isArray, isFunction, EMPTY_OBJ } from '@vue/shared'
|
||||
import { warn } from './warning'
|
||||
import { ComponentInternalInstance } from './component'
|
||||
import { currentRenderingInstance } from './componentRenderUtils'
|
||||
@@ -21,26 +21,26 @@ import { ComponentPublicInstance } from './componentProxy'
|
||||
|
||||
export interface DirectiveBinding {
|
||||
instance: ComponentPublicInstance | null
|
||||
value?: any
|
||||
oldValue?: any
|
||||
value: any
|
||||
oldValue: any
|
||||
arg?: string
|
||||
modifiers?: DirectiveModifiers
|
||||
modifiers: DirectiveModifiers
|
||||
}
|
||||
|
||||
export type DirectiveHook = (
|
||||
el: any,
|
||||
export type DirectiveHook<T = any> = (
|
||||
el: T,
|
||||
binding: DirectiveBinding,
|
||||
vnode: VNode,
|
||||
vnode: VNode<any, T>,
|
||||
prevVNode: VNode | null
|
||||
) => void
|
||||
|
||||
export interface Directive {
|
||||
beforeMount?: DirectiveHook
|
||||
mounted?: DirectiveHook
|
||||
beforeUpdate?: DirectiveHook
|
||||
updated?: DirectiveHook
|
||||
beforeUnmount?: DirectiveHook
|
||||
unmounted?: DirectiveHook
|
||||
export interface Directive<T = any> {
|
||||
beforeMount?: DirectiveHook<T>
|
||||
mounted?: DirectiveHook<T>
|
||||
beforeUpdate?: DirectiveHook<T>
|
||||
updated?: DirectiveHook<T>
|
||||
beforeUnmount?: DirectiveHook<T>
|
||||
unmounted?: DirectiveHook<T>
|
||||
}
|
||||
|
||||
type DirectiveModifiers = Record<string, boolean>
|
||||
@@ -53,7 +53,7 @@ function applyDirective(
|
||||
directive: Directive,
|
||||
value?: any,
|
||||
arg?: string,
|
||||
modifiers?: DirectiveModifiers
|
||||
modifiers: DirectiveModifiers = EMPTY_OBJ
|
||||
) {
|
||||
let valueCacheForDir = valueCache.get(directive)!
|
||||
if (!valueCacheForDir) {
|
||||
|
||||
Reference in New Issue
Block a user