@@ -23,7 +23,8 @@ import {
2323 type SlotBlockIRNode ,
2424 type VaporDirectiveNode ,
2525} from '../ir'
26- import { findDir , resolveExpression } from '../utils'
26+ import { findDir , findProp , resolveExpression } from '../utils'
27+ import { isTransitionNode } from './vIf'
2728
2829export const transformVSlot : NodeTransform = ( node , context ) => {
2930 if ( node . type !== NodeTypes . ELEMENT ) return
@@ -72,7 +73,18 @@ function transformComponentSlot(
7273 ! ( n . type === NodeTypes . ELEMENT && n . props . some ( isVSlot ) ) ,
7374 )
7475
75- const [ block , onExit ] = createSlotBlock ( node , dir , context )
76+ let slotKey
77+ if ( isTransitionNode ( node ) ) {
78+ const keyProp = findProp (
79+ nonSlotTemplateChildren [ 0 ] as ElementNode ,
80+ 'key' ,
81+ ) as VaporDirectiveNode
82+ if ( keyProp ) {
83+ slotKey = keyProp . exp
84+ }
85+ }
86+
87+ const [ block , onExit ] = createSlotBlock ( node , dir , context , slotKey )
7688
7789 const { slots } = context
7890
@@ -233,9 +245,12 @@ function createSlotBlock(
233245 slotNode : ElementNode ,
234246 dir : VaporDirectiveNode | undefined ,
235247 context : TransformContext < ElementNode > ,
248+ key : SimpleExpressionNode | undefined = undefined ,
236249) : [ SlotBlockIRNode , ( ) => void ] {
237250 const block : SlotBlockIRNode = newBlock ( slotNode )
238251 block . props = dir && dir . exp
252+ block . key = key
253+ if ( key ) block . dynamic . needsKey = true
239254 const exitBlock = context . enterBlock ( block )
240255 return [ block , exitBlock ]
241256}
0 commit comments