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

Method outputSlot

compiler/companion/src/JSXProcessor.ts:441–474  ·  view source on GitHub ↗
(
    node: ts.Node,
    children: ts.JsxChild[],
    slotName: ts.Expression | undefined,
    output: JSXOutputState,
    transformContext: ts.TransformationContext,
  )

Source from the content-addressed store, hash-verified

439 }
440
441 private outputSlot(
442 node: ts.Node,
443 children: ts.JsxChild[],
444 slotName: ts.Expression | undefined,
445 output: JSXOutputState,
446 transformContext: ts.TransformationContext,
447 ): ts.Statement[] {
448 const childrenWithoutTexts = children.filter(
449 (child) => !(this.isEmptyJsxExpression(child) || this.isJsxText(child)),
450 );
451 const singleExpr = this.getSingleJsxExpression(childrenWithoutTexts);
452
453 if (singleExpr && this.isNamedSlotsExpression(singleExpr)) {
454 return this.outputNamedSlotsExpression(singleExpr, singleExpr.arguments, output, transformContext);
455 } else if (singleExpr && this.isUnnamedSlotsExpression(singleExpr)) {
456 return [this.outputSlotExpression(singleExpr, singleExpr.arguments, output, transformContext)];
457 } else {
458 const innerStatements = this.outputJSXChildren(node, childrenWithoutTexts, output, transformContext);
459 const lambdaInner = transformContext.factory.createArrowFunction(
460 undefined,
461 undefined,
462 [],
463 undefined,
464 undefined,
465 this.toBlock(innerStatements, transformContext),
466 );
467
468 if (slotName) {
469 return [this.createRendererCall('setNamedSlot', [slotName, lambdaInner], undefined, transformContext)];
470 } else {
471 return [this.createRendererCall('setUnnamedSlot', [lambdaInner], undefined, transformContext)];
472 }
473 }
474 }
475
476 private createConstVariable(
477 variableName: string,

Callers 1

Calls 11

isEmptyJsxExpressionMethod · 0.95
isJsxTextMethod · 0.95
outputSlotExpressionMethod · 0.95
outputJSXChildrenMethod · 0.95
toBlockMethod · 0.95
createRendererCallMethod · 0.95
filterMethod · 0.80

Tested by

no test coverage detected