Skip to content

Commit

Permalink
chore: improve code
Browse files Browse the repository at this point in the history
  • Loading branch information
edison1105 committed Dec 1, 2022
1 parent a38a08d commit 4e22e8f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
16 changes: 3 additions & 13 deletions packages/runtime-core/src/directives.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -105,24 +105,14 @@ export function withDirectives<T extends VNode>(
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
Expand Down
5 changes: 4 additions & 1 deletion packages/server-renderer/src/render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 4e22e8f

Please sign in to comment.