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

@@ -5,7 +5,8 @@ import {
ErrorCodes,
BindingTypes,
NodeTransform,
transformExpression
transformExpression,
baseCompile
} from '../../src'
import {
RESOLVE_COMPONENT,
@@ -66,6 +67,7 @@ function parseWithBind(template: string, options?: CompilerOptions) {
return parseWithElementTransform(template, {
...options,
directiveTransforms: {
...options?.directiveTransforms,
bind: transformBind
}
})
@@ -932,7 +934,11 @@ describe('compiler: element transform', () => {
})
test('NEED_PATCH (vnode hooks)', () => {
const { node } = parseWithBind(`<div @vnodeUpdated="foo" />`)
const root = baseCompile(`<div @vnodeUpdated="foo" />`, {
prefixIdentifiers: true,
cacheHandlers: true
}).ast
const node = (root as any).children[0].codegenNode
expect(node.patchFlag).toBe(genFlagText(PatchFlags.NEED_PATCH))
})