From: zhiyuanzmj <32807958+zhiyuanzmj@users.noreply.github.com> Date: Tue, 17 Sep 2024 03:45:20 +0000 (+0800) Subject: feat(compiler-vapor): support v-slots expression for jsx-vapor (#271) X-Git-Tag: v3.6.0-alpha.1~16^2~323 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ced7ee684c10dd7cd8bbd32bbc6df002ae7650d5;p=thirdparty%2Fvuejs%2Fcore.git feat(compiler-vapor): support v-slots expression for jsx-vapor (#271) Co-authored-by: 三咲智子 Kevin Deng --- diff --git a/packages/compiler-vapor/src/generators/component.ts b/packages/compiler-vapor/src/generators/component.ts index 02ec2aefcb..5971d50c55 100644 --- a/packages/compiler-vapor/src/generators/component.ts +++ b/packages/compiler-vapor/src/generators/component.ts @@ -163,7 +163,9 @@ function genRawSlots(slots: IRSlots[], context: CodegenContext) { ...slots.map(slot => slot.slotType === IRSlotType.STATIC ? genStaticSlots(slot, context) - : genDynamicSlot(slot, context, true), + : slot.slotType === IRSlotType.EXPRESSION + ? slot.slots.content + : genDynamicSlot(slot, context, true), ), ) } diff --git a/packages/compiler-vapor/src/ir/component.ts b/packages/compiler-vapor/src/ir/component.ts index c2bd99f7d4..884636cdfa 100644 --- a/packages/compiler-vapor/src/ir/component.ts +++ b/packages/compiler-vapor/src/ir/component.ts @@ -36,6 +36,7 @@ export enum IRSlotType { DYNAMIC, LOOP, CONDITIONAL, + EXPRESSION, // JSX only } export type IRSlotsStatic = { slotType: IRSlotType.STATIC @@ -58,9 +59,13 @@ export interface IRSlotDynamicConditional { positive: IRSlotDynamicBasic negative?: IRSlotDynamicBasic | IRSlotDynamicConditional } +export interface IRSlotsExpression { + slotType: IRSlotType.EXPRESSION + slots: SimpleExpressionNode +} export type IRSlotDynamic = | IRSlotDynamicBasic | IRSlotDynamicLoop | IRSlotDynamicConditional -export type IRSlots = IRSlotsStatic | IRSlotDynamic +export type IRSlots = IRSlotsStatic | IRSlotDynamic | IRSlotsExpression