feat(ssr): support custom directive getSSRProps in optimized compilation
close #5304
This commit is contained in:
@@ -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))
|
||||
})
|
||||
|
||||
|
||||
@@ -54,7 +54,9 @@ export {
|
||||
export {
|
||||
transformElement,
|
||||
resolveComponentType,
|
||||
buildProps
|
||||
buildProps,
|
||||
buildDirectiveArgs,
|
||||
PropsExpression
|
||||
} from './transforms/transformElement'
|
||||
export { processSlotOutlet } from './transforms/transformSlotOutlet'
|
||||
export { generateCodeFrame } from '@vue/shared'
|
||||
|
||||
@@ -29,7 +29,8 @@ import {
|
||||
isObject,
|
||||
isReservedProp,
|
||||
capitalize,
|
||||
camelize
|
||||
camelize,
|
||||
isBuiltInDirective
|
||||
} from '@vue/shared'
|
||||
import { createCompilerError, ErrorCodes } from '../errors'
|
||||
import {
|
||||
@@ -665,7 +666,7 @@ export function buildProps(
|
||||
directiveImportMap.set(prop, needRuntime)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
} else if (!isBuiltInDirective(name)) {
|
||||
// no built-in transform, this is a user custom directive.
|
||||
runtimeDirectives.push(prop)
|
||||
// custom dirs may use beforeUpdate so they need to force blocks
|
||||
@@ -853,7 +854,7 @@ function mergeAsArray(existing: Property, incoming: Property) {
|
||||
}
|
||||
}
|
||||
|
||||
function buildDirectiveArgs(
|
||||
export function buildDirectiveArgs(
|
||||
dir: DirectiveNode,
|
||||
context: TransformContext
|
||||
): ArrayExpression {
|
||||
|
||||
Reference in New Issue
Block a user