@@ -23,7 +23,8 @@ import {
23
23
type SlotBlockIRNode ,
24
24
type VaporDirectiveNode ,
25
25
} from '../ir'
26
- import { findDir , resolveExpression } from '../utils'
26
+ import { findDir , findProp , resolveExpression } from '../utils'
27
+ import { isTransitionNode } from './vIf'
27
28
28
29
export const transformVSlot : NodeTransform = ( node , context ) => {
29
30
if ( node . type !== NodeTypes . ELEMENT ) return
@@ -72,7 +73,18 @@ function transformComponentSlot(
72
73
! ( n . type === NodeTypes . ELEMENT && n . props . some ( isVSlot ) ) ,
73
74
)
74
75
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 )
76
88
77
89
const { slots } = context
78
90
@@ -233,9 +245,12 @@ function createSlotBlock(
233
245
slotNode : ElementNode ,
234
246
dir : VaporDirectiveNode | undefined ,
235
247
context : TransformContext < ElementNode > ,
248
+ key : SimpleExpressionNode | undefined = undefined ,
236
249
) : [ SlotBlockIRNode , ( ) => void ] {
237
250
const block : SlotBlockIRNode = newBlock ( slotNode )
238
251
block . props = dir && dir . exp
252
+ block . key = key
253
+ if ( key ) block . dynamic . needsKey = true
239
254
const exitBlock = context . enterBlock ( block )
240
255
return [ block , exitBlock ]
241
256
}
0 commit comments