@@ -16,7 +16,7 @@ import {
1616 isVNode ,
1717 openBlock ,
1818} from '../vnode'
19- import { PatchFlags , SlotFlags , isSymbol } from '@vue/shared'
19+ import { PatchFlags , SlotFlags , extend , isSymbol } from '@vue/shared'
2020import { warn } from '../warning'
2121import { isAsyncWrapper } from '../apiAsyncComponent'
2222
@@ -32,24 +32,29 @@ export function renderSlot(
3232 // the compiler and guaranteed to be a function returning an array
3333 fallback ?: ( ) => VNodeArrayChildren ,
3434 noSlotted ?: boolean ,
35+ branchKey ?: PropertyKey ,
3536) : VNode {
3637 if (
3738 currentRenderingInstance ! . ce ||
3839 ( currentRenderingInstance ! . parent &&
3940 isAsyncWrapper ( currentRenderingInstance ! . parent ) &&
4041 currentRenderingInstance ! . parent . ce )
4142 ) {
42- const hasProps = Object . keys ( props ) . length > 0
43+ const slotProps =
44+ branchKey != null && props . key == null
45+ ? extend ( { } , props , { key : branchKey } )
46+ : props
47+ const hasProps = Object . keys ( slotProps ) . length > 0
4348 // in custom element mode, render <slot/> as actual slot outlets
4449 // wrap it with a fragment because in shadowRoot: false mode the slot
4550 // element gets replaced by injected content
46- if ( name !== 'default' ) props . name = name
51+ if ( name !== 'default' ) slotProps . name = name
4752 return (
4853 openBlock ( ) ,
4954 createBlock (
5055 Fragment ,
5156 null ,
52- [ createVNode ( 'slot' , props , fallback && fallback ( ) ) ] ,
57+ [ createVNode ( 'slot' , slotProps , fallback && fallback ( ) ) ] ,
5358 hasProps ? PatchFlags . BAIL : PatchFlags . STABLE_FRAGMENT ,
5459 )
5560 )
@@ -80,6 +85,7 @@ export function renderSlot(
8085 const validSlotContent = slot && ensureValidVNode ( slot ( props ) )
8186 const slotKey =
8287 props . key ||
88+ branchKey ||
8389 // slot content array of a dynamic conditional slot may have a branch
8490 // key attached in the `createSlots` helper, respect that
8591 ( validSlotContent && ( validSlotContent as any ) . key )
0 commit comments