MCPcopy
hub / github.com/vuejs/core / buildSSRProps

Function buildSSRProps

packages/compiler-ssr/src/transforms/ssrTransformElement.ts:374–402  ·  view source on GitHub ↗
(
  props: PropsExpression | undefined,
  directives: DirectiveNode[],
  context: TransformContext,
)

Source from the content-addressed store, hash-verified

372}
373
374export function buildSSRProps(
375 props: PropsExpression | undefined,
376 directives: DirectiveNode[],
377 context: TransformContext,
378): JSChildNode {
379 let mergePropsArgs: JSChildNode[] = []
380 if (props) {
381 if (props.type === NodeTypes.JS_CALL_EXPRESSION) {
382 // already a mergeProps call
383 mergePropsArgs = props.arguments as JSChildNode[]
384 } else {
385 mergePropsArgs.push(props)
386 }
387 }
388 if (directives.length) {
389 for (const dir of directives) {
390 mergePropsArgs.push(
391 createCallExpression(context.helper(SSR_GET_DIRECTIVE_PROPS), [
392 `_ctx`,
393 ...buildDirectiveArgs(dir, context).elements,
394 ] as JSChildNode[]),
395 )
396 }
397 }
398
399 return mergePropsArgs.length > 1
400 ? createCallExpression(context.helper(MERGE_PROPS), mergePropsArgs)
401 : mergePropsArgs[0]
402}
403
404function isTrueFalseValue(prop: DirectiveNode | AttributeNode) {
405 if (prop.type === NodeTypes.DIRECTIVE) {

Callers 3

ssrTransformComponentFunction · 0.90
ssrTransformElementFunction · 0.85

Calls 4

createCallExpressionFunction · 0.85
buildDirectiveArgsFunction · 0.85
pushMethod · 0.65
helperMethod · 0.65

Tested by

no test coverage detected