(jsxElement: JSXElement, transformContext: ts.TransformationContext)
| 716 | } |
| 717 | |
| 718 | private outputRenderSlot(jsxElement: JSXElement, transformContext: ts.TransformationContext): ts.Statement { |
| 719 | let slotName: ts.Expression | undefined; |
| 720 | let slotRef: ts.Expression | undefined; |
| 721 | let slotKey: ts.Expression | undefined; |
| 722 | for (const attribute of jsxElement.attributes) { |
| 723 | if (attribute.name === 'name') { |
| 724 | slotName = attribute.value.value; |
| 725 | } else if (attribute.name === 'ref') { |
| 726 | slotRef = attribute.value.value; |
| 727 | } else if (attribute.name === 'key') { |
| 728 | slotKey = attribute.value.value; |
| 729 | } else { |
| 730 | this.onError(jsxElement.element, `Unsupported attribute '${attribute.name}' in slot`); |
| 731 | } |
| 732 | } |
| 733 | |
| 734 | if (jsxElement.children.length) { |
| 735 | this.onError(jsxElement.element, 'Cannot declare children in a slot'); |
| 736 | } |
| 737 | |
| 738 | const thisParameter = transformContext.factory.createThis(); |
| 739 | |
| 740 | if (slotName) { |
| 741 | const parameters = [slotName, thisParameter, slotRef, slotKey]; |
| 742 | |
| 743 | return this.createRendererCall( |
| 744 | 'renderNamedSlot', |
| 745 | this.toParametersArray(parameters, transformContext), |
| 746 | jsxElement.element, |
| 747 | transformContext, |
| 748 | ); |
| 749 | } else { |
| 750 | const parameters = [thisParameter, slotRef, slotKey]; |
| 751 | |
| 752 | return this.createRendererCall( |
| 753 | 'renderUnnamedSlot', |
| 754 | this.toParametersArray(parameters, transformContext), |
| 755 | jsxElement.element, |
| 756 | transformContext, |
| 757 | ); |
| 758 | } |
| 759 | } |
| 760 | |
| 761 | private getJsxNodeKind(tag: ts.JsxTagNameExpression, nodeTypeStr: string, output: JSXOutputState): JSXNodeKind { |
| 762 | if (ts.isIdentifier(tag)) { |
no test coverage detected