feat(ssr): support custom directive getSSRProps in optimized compilation

close #5304
This commit is contained in:
Evan You
2022-02-04 08:58:28 +08:00
parent a51f935b72
commit 60cf175d88
14 changed files with 228 additions and 45 deletions

View File

@@ -0,0 +1,26 @@
import { ComponentPublicInstance, Directive } from '@vue/runtime-core'
export function ssrGetDirectiveProps(
instance: ComponentPublicInstance,
dir: Directive,
value?: any,
arg?: string,
modifiers: Record<string, boolean> = {}
): Record<string, any> {
if (typeof dir !== 'function' && dir.getSSRProps) {
return (
dir.getSSRProps(
{
dir,
instance,
value,
oldValue: undefined,
arg,
modifiers
},
null as any
) || {}
)
}
return {}
}

View File

@@ -30,6 +30,7 @@ export {
export { ssrInterpolate } from './helpers/ssrInterpolate'
export { ssrRenderList } from './helpers/ssrRenderList'
export { ssrRenderSuspense } from './helpers/ssrRenderSuspense'
export { ssrGetDirectiveProps } from './helpers/ssrGetDirectiveProps'
export { includeBooleanAttr as ssrIncludeBooleanAttr } from '@vue/shared'
// v-model helpers