(
jsxElement: JSXElement,
output: JSXOutputState,
transformContext: ts.TransformationContext,
)
| 1047 | } |
| 1048 | |
| 1049 | private outputJSX( |
| 1050 | jsxElement: JSXElement, |
| 1051 | output: JSXOutputState, |
| 1052 | transformContext: ts.TransformationContext, |
| 1053 | ): ts.Statement[] { |
| 1054 | const nodeTypeStr = jsxElement.nodeType.getText(); |
| 1055 | |
| 1056 | const nodeKind = this.getJsxNodeKind(jsxElement.nodeType, nodeTypeStr, output); |
| 1057 | const attributeStatements = this.resolveJSXAttributeStatements(nodeKind, jsxElement, transformContext); |
| 1058 | |
| 1059 | let nodeOutput: JSXNodeOutput; |
| 1060 | |
| 1061 | switch (nodeKind) { |
| 1062 | case JSXNodeKind.element: |
| 1063 | nodeOutput = this.outputJSXElement(jsxElement, output, transformContext, nodeTypeStr, attributeStatements); |
| 1064 | break; |
| 1065 | case JSXNodeKind.slot: |
| 1066 | nodeOutput = this.outputJSXSlot(jsxElement, output, transformContext, nodeTypeStr, attributeStatements); |
| 1067 | break; |
| 1068 | case JSXNodeKind.component: |
| 1069 | nodeOutput = this.outputJSXComponent(jsxElement, output, transformContext, nodeTypeStr, attributeStatements); |
| 1070 | break; |
| 1071 | case JSXNodeKind.functionComponent: |
| 1072 | nodeOutput = this.outputJSXFunctionComponent( |
| 1073 | jsxElement, |
| 1074 | output, |
| 1075 | transformContext, |
| 1076 | nodeTypeStr, |
| 1077 | attributeStatements, |
| 1078 | ); |
| 1079 | break; |
| 1080 | } |
| 1081 | |
| 1082 | ts.setTextRange(nodeOutput.beginRenderStatement, jsxElement.element.tagName); |
| 1083 | if (nodeOutput.endRenderStatement) { |
| 1084 | if (jsxElement.closingElement) { |
| 1085 | ts.setTextRange(nodeOutput.endRenderStatement, jsxElement.closingElement.tagName); |
| 1086 | } else if (ts.isJsxSelfClosingElement(jsxElement.element)) { |
| 1087 | // We set the text range of the endComponent/endRender on the slash element |
| 1088 | // of the self closing element. |
| 1089 | let slashElement: ts.Node | undefined; |
| 1090 | for (const child of jsxElement.element.getChildren()) { |
| 1091 | if (child.kind === ts.SyntaxKind.SlashToken) { |
| 1092 | slashElement = child; |
| 1093 | } |
| 1094 | } |
| 1095 | |
| 1096 | if (slashElement) { |
| 1097 | ts.setTextRange(nodeOutput.endRenderStatement, slashElement); |
| 1098 | } else { |
| 1099 | this.logger?.error?.('Could not find Slash element in JSX self closing element'); |
| 1100 | } |
| 1101 | } |
| 1102 | } |
| 1103 | |
| 1104 | return nodeOutput.statements; |
| 1105 | } |
| 1106 |
no test coverage detected