You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Scoped slot transforms array argument if rendered conditionally #15048
Create a component with a scoped slot that is rendered conditionally
Pass an array as the sole argument to the slot
What is expected?
Array is rendered normally.
If you render items of that array in v-for loop, you only see items inside that array
What is actually happening?
Array is transformed into object. Items and their indexes are staying the same, key field is added
System Info
Any additional comments?
key attribute is generated by the compiler for the slot rendered with v-if.
While this is not explicitly mentioned in documentation, one can assume that the expectation is that slotProps is always an object, as this is what will be passed to the slot if you use multiple v-bind directives on the slot.
This issue is rather pointing out the difference in behavior of the slot when v-if is present or not present.
I took a look at this and the root cause seems to be that the compiler-injected branch key for the conditional slot outlet is leaking into the scoped slot props.
For this template, the conditional slot is compiled roughly as:
The injected key is needed by v-if/branch codegen so renderSlot can produce a stable fragment key. However, renderSlot currently uses the same props object both as metadata for the rendered slot fragment and as the object passed to the user slot function. When v-bind receives an array, mergeProps treats it like an object and enumerates its indexes, so the parent slot receives an object like { 0: 'item1', 1: 'item2', 2: 'item3', key: 0 } instead of the original array-like value.
So this is not the source array being mutated; it is the internal branch key being merged into the slot props object and exposed to userland. A fix probably needs to distinguish compiler-injected slot outlet keys from user-provided slot props, so renderSlot can still use the key for fragment identity without passing that internal key through to the scoped slot.
Activity
DaZuiZui commentedon Jul 7, 2026
I took a look at this and the root cause seems to be that the compiler-injected branch key for the conditional slot outlet is leaking into the scoped slot props.
For this template, the conditional slot is compiled roughly as:
The injected
keyis needed byv-if/branch codegen sorenderSlotcan produce a stable fragment key. However,renderSlotcurrently uses the same props object both as metadata for the rendered slot fragment and as the object passed to the user slot function. Whenv-bindreceives an array,mergePropstreats it like an object and enumerates its indexes, so the parent slot receives an object like{ 0: 'item1', 1: 'item2', 2: 'item3', key: 0 }instead of the original array-like value.So this is not the source array being mutated; it is the internal branch key being merged into the slot props object and exposed to userland. A fix probably needs to distinguish compiler-injected slot outlet keys from user-provided slot props, so
renderSlotcan still use the key for fragment identity without passing that internal key through to the scoped slot.I'll work on this.
fix(compiler-core): avoid leaking slot branch keys (#15051)