MCPcopy Create free account
hub / github.com/Snapchat/Valdi / outputComponentChildren

Method outputComponentChildren

compiler/companion/src/JSXProcessor.ts:652–704  ·  view source on GitHub ↗
(
    node: ts.Node,
    children: ts.JsxChild[],
    output: JSXOutputState,
    transformContext: ts.TransformationContext,
  )

Source from the content-addressed store, hash-verified

650 }
651
652 private outputComponentChildren(
653 node: ts.Node,
654 children: ts.JsxChild[],
655 output: JSXOutputState,
656 transformContext: ts.TransformationContext,
657 ): ts.Statement[] {
658 const slotteds: Slotted[] = [];
659 let hasExplicitSlotted = false;
660 let hasImplicitSlotted = false;
661
662 for (const child of children) {
663 if (this.isEmptyJsxExpression(child) || this.isJsxText(child)) {
664 continue;
665 }
666
667 if (ts.isJsxElement(child) && child.openingElement.tagName.getText() === 'slotted') {
668 hasExplicitSlotted = true;
669
670 const slotName = this.getSlotValueExpr(child.openingElement.attributes, output, transformContext);
671 if (slotName) {
672 slotteds.push({ slotName, expressions: child.children.map((item) => item) });
673 } else {
674 this.insertChildrenToUnnamedSlot(
675 child.children.map((item) => item),
676 slotteds,
677 );
678 }
679 } else if (ts.isJsxSelfClosingElement(child) && child.tagName.getText() === 'slotted') {
680 hasExplicitSlotted = true;
681
682 const slotName = this.getSlotValueExpr(child.attributes, output, transformContext);
683 if (slotName) {
684 slotteds.push({ slotName, expressions: [] });
685 } else {
686 this.insertChildrenToUnnamedSlot([], slotteds);
687 }
688 } else {
689 hasImplicitSlotted = true;
690
691 this.insertChildrenToUnnamedSlot([child], slotteds);
692 }
693
694 this.ensureImplicitSlottedNotUsedWithExplicit(node, hasExplicitSlotted, hasImplicitSlotted);
695 }
696
697 const statements: ts.Statement[] = [];
698
699 for (const slotted of slotteds) {
700 statements.push(...this.outputSlot(node, slotted.expressions, slotted.slotName, output, transformContext));
701 }
702
703 return statements;
704 }
705
706 private toParametersArray(
707 parameters: readonly (ts.Expression | undefined)[],

Callers 1

outputJSXComponentMethod · 0.95

Calls 9

isEmptyJsxExpressionMethod · 0.95
isJsxTextMethod · 0.95
getSlotValueExprMethod · 0.95
outputSlotMethod · 0.95
getTextMethod · 0.65
pushMethod · 0.45
mapMethod · 0.45

Tested by

no test coverage detected