From 4e22e8fc84bff9c79fbde4b48259cd0b1750d3a2 Mon Sep 17 00:00:00 2001 From: daiwei Date: Thu, 1 Dec 2022 09:00:06 +0800 Subject: [PATCH] chore: improve code --- packages/runtime-core/src/directives.ts | 16 +++------------- packages/server-renderer/src/render.ts | 5 ++++- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/packages/runtime-core/src/directives.ts b/packages/runtime-core/src/directives.ts index f90dcd550af..18c3352b002 100644 --- a/packages/runtime-core/src/directives.ts +++ b/packages/runtime-core/src/directives.ts @@ -11,7 +11,7 @@ return withDirectives(h(comp), [ ]) */ -import { mergeProps, VNode } from './vnode' +import { VNode } from './vnode' import { isFunction, EMPTY_OBJ, isBuiltInDirective } from '@vue/shared' import { warn } from './warning' import { ComponentInternalInstance, Data, getExposeProxy } from './component' @@ -105,24 +105,14 @@ export function withDirectives( if (dir.deep) { traverse(value) } - const binding = { + bindings.push({ dir, instance, value, oldValue: void 0, arg, modifiers - } - - // #6123 - // apply ssr props to the the fallback vnode-based branch in ssr - if (dir.getSSRProps) { - vnode.props = mergeProps( - vnode.props || {}, - dir.getSSRProps(binding, vnode) || {} - ) - } - bindings.push(binding) + }) } } return vnode diff --git a/packages/server-renderer/src/render.ts b/packages/server-renderer/src/render.ts index a1f327b4320..acb81406aeb 100644 --- a/packages/server-renderer/src/render.ts +++ b/packages/server-renderer/src/render.ts @@ -218,7 +218,10 @@ export function renderVNode( parentComponent: ComponentInternalInstance, slotScopeId?: string ) { - const { type, shapeFlag, children } = vnode + const { type, shapeFlag, children, dirs, props } = vnode + if (dirs) { + vnode.props = applySSRDirectives(vnode, props, dirs) + } switch (type) { case Text: push(escapeHtml(children as string))