( node: ElementNode, context: TransformContext, props: ElementNode['props'] | undefined = node.props, isComponent: boolean, isDynamicComponent: boolean, ssr = false, )
| 372 | export type PropsExpression = ObjectExpression | CallExpression | ExpressionNode |
| 373 | |
| 374 | export 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 ( |
no test coverage detected