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

Function buildProps

packages/compiler-core/src/transforms/transformElement.ts:374–831  ·  view source on GitHub ↗
(
  node: ElementNode,
  context: TransformContext,
  props: ElementNode['props'] | undefined = node.props,
  isComponent: boolean,
  isDynamicComponent: boolean,
  ssr = false,
)

Source from the content-addressed store, hash-verified

372export type PropsExpression = ObjectExpression | CallExpression | ExpressionNode
373
374export function buildProps(
375 node: ElementNode,
376 context: TransformContext,
377 props: ElementNode['props'] | undefined = node.props,
378 isComponent: boolean,
379 isDynamicComponent: boolean,
380 ssr = false,
381): {
382 props: PropsExpression | undefined
383 directives: DirectiveNode[]
384 patchFlag: number
385 dynamicPropNames: string[]
386 shouldUseBlock: boolean
387} {
388 const { tag, loc: elementLoc, children } = node
389 let properties: ObjectExpression['properties'] = []
390 const mergeArgs: PropsExpression[] = []
391 const runtimeDirectives: DirectiveNode[] = []
392 const hasChildren = children.length > 0
393 let shouldUseBlock = false
394
395 // patchFlag analysis
396 let patchFlag = 0
397 let hasRef = false
398 let hasClassBinding = false
399 let hasStyleBinding = false
400 let hasHydrationEventBinding = false
401 let hasDynamicKeys = false
402 let hasVnodeHook = false
403 const dynamicPropNames: string[] = []
404
405 const pushMergeArg = (arg?: PropsExpression) => {
406 if (properties.length) {
407 mergeArgs.push(
408 createObjectExpression(dedupeProperties(properties), elementLoc),
409 )
410 properties = []
411 }
412 if (arg) mergeArgs.push(arg)
413 }
414
415 // mark template ref on v-for
416 const pushRefVForMarker = () => {
417 if (context.scopes.vFor > 0) {
418 properties.push(
419 createObjectProperty(
420 createSimpleExpression('ref_for', true),
421 createSimpleExpression('true'),
422 ),
423 )
424 }
425 }
426
427 const analyzePatchFlag = ({ key, value }: Property) => {
428 if (isStaticExp(key)) {
429 const name = key.content
430 const isEventHandler = isOn(name)
431 if (

Callers 5

processSlotOutletFunction · 0.90
ssrTransformComponentFunction · 0.85
ssrTransformElementFunction · 0.85
transformElementFunction · 0.85

Calls 15

createObjectPropertyFunction · 0.90
createSimpleExpressionFunction · 0.90
isCompatEnabledFunction · 0.90
createCompilerErrorFunction · 0.90
isStaticArgOfFunction · 0.90
isOnFunction · 0.90
checkCompatEnabledFunction · 0.90
isStaticExpFunction · 0.90
createObjectExpressionFunction · 0.90
isSymbolFunction · 0.90
createCallExpressionFunction · 0.90
pushRefVForMarkerFunction · 0.85

Tested by

no test coverage detected