refactor: applyDirectives -> withDirectives

This commit is contained in:
Evan You
2019-10-18 16:35:01 -04:00
parent cba34453db
commit e98a85f3cb
20 changed files with 63 additions and 64 deletions

View File

@@ -11,8 +11,8 @@ return applyDirectives(h(comp), [
])
*/
import { VNode, cloneVNode } from './vnode'
import { extend, isArray, isFunction, EMPTY_OBJ, makeMap } from '@vue/shared'
import { VNode } from './vnode'
import { isArray, isFunction, EMPTY_OBJ, makeMap } from '@vue/shared'
import { warn } from './warning'
import { ComponentInternalInstance } from './component'
import { currentRenderingInstance } from './componentRenderUtils'
@@ -120,11 +120,10 @@ export type DirectiveArguments = Array<
| [Directive, any, string, DirectiveModifiers]
>
export function applyDirectives(vnode: VNode, directives: DirectiveArguments) {
export function withDirectives(vnode: VNode, directives: DirectiveArguments) {
const instance = currentRenderingInstance
if (instance !== null) {
vnode = cloneVNode(vnode)
vnode.props = vnode.props != null ? extend({}, vnode.props) : {}
vnode.props = vnode.props || {}
for (let i = 0; i < directives.length; i++) {
const [dir, value, arg, modifiers] = directives[i]
applyDirective(vnode.props, instance, dir, value, arg, modifiers)

View File

@@ -38,7 +38,7 @@ export {
// Internal, for compiler generated code
// should sync with '@vue/compiler-core/src/runtimeConstants.ts'
export { applyDirectives } from './directives'
export { withDirectives } from './directives'
export {
resolveComponent,
resolveDirective,