(node, context)
| 71 | |
| 72 | // generate a JavaScript AST for this element's codegen |
| 73 | export const transformElement: NodeTransform = (node, context) => { |
| 74 | // perform the work on exit, after all child expressions have been |
| 75 | // processed and merged. |
| 76 | return function postTransformElement() { |
| 77 | node = context.currentNode! |
| 78 | |
| 79 | if ( |
| 80 | !( |
| 81 | node.type === NodeTypes.ELEMENT && |
| 82 | (node.tagType === ElementTypes.ELEMENT || |
| 83 | node.tagType === ElementTypes.COMPONENT) |
| 84 | ) |
| 85 | ) { |
| 86 | return |
| 87 | } |
| 88 | |
| 89 | const { tag, props } = node |
| 90 | const isComponent = node.tagType === ElementTypes.COMPONENT |
| 91 | |
| 92 | // The goal of the transform is to create a codegenNode implementing the |
| 93 | // VNodeCall interface. |
| 94 | let vnodeTag = isComponent |
| 95 | ? resolveComponentType(node as ComponentNode, context) |
| 96 | : `"${tag}"` |
| 97 | |
| 98 | const isDynamicComponent = |
| 99 | isObject(vnodeTag) && vnodeTag.callee === RESOLVE_DYNAMIC_COMPONENT |
| 100 | |
| 101 | let vnodeProps: VNodeCall['props'] |
| 102 | let vnodeChildren: VNodeCall['children'] |
| 103 | let patchFlag: VNodeCall['patchFlag'] | 0 = 0 |
| 104 | let vnodeDynamicProps: VNodeCall['dynamicProps'] |
| 105 | let dynamicPropNames: string[] | undefined |
| 106 | let vnodeDirectives: VNodeCall['directives'] |
| 107 | |
| 108 | let shouldUseBlock = |
| 109 | // dynamic component may resolve to plain elements |
| 110 | isDynamicComponent || |
| 111 | vnodeTag === TELEPORT || |
| 112 | vnodeTag === SUSPENSE || |
| 113 | (!isComponent && |
| 114 | // <svg> and <foreignObject> must be forced into blocks so that block |
| 115 | // updates inside get proper isSVG flag at runtime. (#639, #643) |
| 116 | // This is technically web-specific, but splitting the logic out of core |
| 117 | // leads to too much unnecessary complexity. |
| 118 | (tag === 'svg' || tag === 'foreignObject' || tag === 'math')) |
| 119 | |
| 120 | // props |
| 121 | if (props.length > 0) { |
| 122 | const propsBuildResult = buildProps( |
| 123 | node, |
| 124 | context, |
| 125 | undefined, |
| 126 | isComponent, |
| 127 | isDynamicComponent, |
| 128 | ) |
| 129 | vnodeProps = propsBuildResult.props |
| 130 | patchFlag = propsBuildResult.patchFlag |
nothing calls this directly
no test coverage detected