Backtestsvuerun-20261013-093701#15048

Issue #15048 Merged fix PR #15051 Run 13 Oct 2026 · run-20261013-093701 vuejs/core

Scoped slot transforms array argument if rendered conditionally

Better

Our patch was judged better than the merged fix.

In this judgment, Patch B = our agent, Patch A = the merged fix.

Both patches fix the core issue the same way. When a `<slot v-bind="expr">` gets a compiler-injected key (from v-if branches or a keyed template v-for), the key goes to a new 6th `renderSlot` argument instead of being merged into the props with `mergeProps`. The array therefore reaches the slot unchanged. The differences favour B.

1. **Scope of the compiler change.** Patch A sends every injected `key` on a slot outlet through the new argument, including plain object props. This changes existing snapshot output, e.g. `{ key: 0 }` becomes `{}, undefined, undefined, 0`. That churn is wider than needed. Patch B only takes the new path when props are a single call expression (the `v-bind="expr"` case that causes the bug) and leaves object-literal props unchanged. That is lower risk and keeps existing output stable.

2. **Null props.** With `v-bind="null"`, `normalizeProps(guardReactiveProps(null))` returns null. Before either patch, `mergeProps` turned this into an object. Under Patch A, `renderSlot` would then read `props.key` on null and throw, which is a regression. Patch B guards with `if (!props) props = {}` and adds an integration test for it.

3. **The v-for path.** For `<slot v-bind>` inside v-for, `buildProps` still wraps the props in `mergeProps({ref_for: true}, expr)`, which turns arrays into objects in the same way. Patch B skips that marker for slot outlets, since refs mean nothing on slots, so arrays are preserved there too. Patch A does not touch this, so the same bug can still occur in v-for.

4. **Tests.** Patch B's tests exercise the real scenario end to end:
   - v-if/v-else slots with array props, checking `Array.isArray` at render time;
   - a keyed v-for that confirms elements are still moved by key;
   - a custom-element test showing the key is applied without mutating user props;
   - an SSR check.

   Patch A's tests are mostly codegen-shape checks and runtime unit tests of `renderSlot`. It has no end-to-end test of the issue's array case under v-if.

Overall, B fixes the root cause more completely, with less churn and better edge-case handling.

The judge saw only the two patches, labelled A and B in random order, with issue links and version numbers removed. The reasoning above is shown verbatim.

Solve

14m 47s

Wall-clock time in the container

Full test suite

No new failures

3,131 passed · 2 skipped · 3,135 total

Contamination audit

Clean

No sign the agent saw the real fix

Patch size

252vs 266 merged

Changed lines, ours vs merged

Vue version

3.5.0

Link to minimal reproduction

https://play.vuejs.org/#eNqFUk1v00AQ/SvDXgxSYqsEDgSnEqBKwAEQReLAoiq1J+m2+6XdtZvK8n/v7Dp2oyptb7Pz3s68mTcd+2Rt3jbIlqz0lRM2gMfQ2FOuhbLGBejA4QZ62DijICNqNkFfjLL7fF7ER6yUfeSa68poH0D5Lazi/9fZV5TSwF/jZP0qe8N1WQztqBE9Aior1wHpBVCmuu3cSxNWnAkCPWcJAug6SAno+8RNfQkri4MabMaCJwkbsc2vvdE0XRfZnFXEFhLdTxsESeRsCQmJ2JoU3n5PueAanI356gqrmyP5a7+LOc5+OfToWuRswsLabTEM8Nn5D9xRPIHK1I0k9jPgb/RGNlHjQPvc6JpkH/CS2m/JCKG3f/zZLqD241BRaGT2ic8ZGRMX9dToD3IX+bv0j+uetjiaeuQ8BocHL1bwL4vRSTaDFLwdg0X2n+7hObNr0e6tLb1d69Nzcp1ORtfosAZtnKJJ76hCBMtLB8VEj8x2fil0/XAme7gsxrqxAfhwJ5FIiuYUeh6MXcKJQzWd1bHeNGEt4q5eECA2B+1f0PP4TC9adNE0WvAif58vPrD+HmmCLos=

Steps to reproduce

  1. Create a component with a scoped slot that is rendered conditionally
  2. 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

<img width="383" height="111" alt="Image" src="https://github.com/user-attachments/assets/338bc873-5c20-4fb3-aed9-88f9f8e8cd98" />

System Info

Any additional comments?

key attribute is generated by the compiler for the slot rendered with v-if.

<img width="781" height="243" alt="Image" src="https://github.com/user-attachments/assets/99704cf9-71cb-435d-ba6f-92578b65ff5d" />

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.

The two patches

Our patch+248 −4
packages/compiler-core/__tests__/transforms/vFor.spec.tsindex 34991445c..302832022 100644@@ -18,7 +18,12 @@ import { } from '../../src/ast' import { ErrorCodes } from '../../src/errors' import { type CompilerOptions, generate } from '../../src'-import { FRAGMENT, RENDER_LIST, RENDER_SLOT } from '../../src/runtimeHelpers'+import {+  FRAGMENT,+  NORMALIZE_PROPS,+  RENDER_LIST,+  RENDER_SLOT,+} from '../../src/runtimeHelpers' import { PatchFlags } from '@vue/shared' import { createObjectMatcher } from '../testUtils' import { transformVBindShorthand } from '../../src/transforms/transformVBindShorthand'@@ -941,6 +946,53 @@ describe('compiler: v-for', () => {       expect(generate(root).code).toMatchSnapshot()     }) +    test('template v-for key injection w/ single <slot v-bind/> child', () => {+      const {+        root,+        node: { codegenNode },+      } = parseWithForTransform(+        '<template v-for="item in items" :key="item.id"><slot v-bind="item.list" /></template>',+        { prefixIdentifiers: true },+      )+      // props must be passed as-is (not merged with the key), the key is+      // passed as the dedicated 6th argument of renderSlot() instead+      expect(+        assertSharedCodegen(codegenNode, true, true /* custom return */),+      ).toMatchObject({+        returns: {+          type: NodeTypes.JS_CALL_EXPRESSION,+          callee: RENDER_SLOT,+          arguments: [+            '_ctx.$slots',+            '"default"',+            { callee: NORMALIZE_PROPS },+            'undefined',+            'undefined',+            expect.anything(),+          ],+        },+      })+      const { code } = generate(root)+      expect(code).not.toMatch(`mergeProps`)+      expect(code).not.toMatch(`ref_for`)+      expect(code).toMatch(+        `_renderSlot(_ctx.$slots, "default", _normalizeProps(_guardReactiveProps(item.list)), undefined, undefined, item.id)`,+      )+    })++    test('v-for on <slot v-bind/> should not merge props', () => {+      const { root } = parseWithForTransform(+        '<slot v-for="item in items" v-bind="item" />',+        { prefixIdentifiers: true },+      )+      const { code } = generate(root)+      expect(code).not.toMatch(`mergeProps`)+      expect(code).not.toMatch(`ref_for`)+      expect(code).toMatch(+        `_renderSlot(_ctx.$slots, "default", _normalizeProps(_guardReactiveProps(item)))`,+      )+    })+     test('v-for on <slot/>', () => {       const {         root,packages/compiler-core/__tests__/transforms/vIf.spec.tsindex fe3aef714..a2703198d 100644@@ -112,6 +112,51 @@ describe('compiler: v-if', () => {       ).toBe(true)     }) +    test('v-if on <slot/> w/ single v-bind expression', () => {+      const {+        root,+        node: { codegenNode },+      } = parseWithIfTransform(+        `<slot v-if="ok" v-bind="arr"></slot><slot v-else v-bind="arr"></slot>`,+      )+      // props must be passed as-is (not merged with the branch key), the key+      // is passed as the dedicated 6th argument instead+      expect(codegenNode).toMatchObject({+        consequent: {+          type: NodeTypes.JS_CALL_EXPRESSION,+          callee: RENDER_SLOT,+          arguments: [+            '$slots',+            '"default"',+            { callee: NORMALIZE_PROPS },+            'undefined',+            'undefined',+            { content: '0' },+          ],+        },+        alternate: {+          type: NodeTypes.JS_CALL_EXPRESSION,+          callee: RENDER_SLOT,+          arguments: [+            '$slots',+            '"default"',+            { callee: NORMALIZE_PROPS },+            'undefined',+            'undefined',+            { content: '1' },+          ],+        },+      })+      const { code } = generate(root)+      expect(code).not.toMatch(`mergeProps`)+      expect(code).toMatch(+        `_renderSlot($slots, "default", _normalizeProps(_guardReactiveProps(arr)), undefined, undefined, 0)`,+      )+      expect(code).toMatch(+        `_renderSlot($slots, "default", _normalizeProps(_guardReactiveProps(arr)), undefined, undefined, 1)`,+      )+    })+     test('v-if + v-else', () => {       const { node } = parseWithIfTransform(`<div v-if="ok"/><p v-else/>`)       expect(node.type).toBe(NodeTypes.IF)packages/compiler-core/src/transforms/transformElement.tsindex 40f08d45b..eb0abca3d 100644@@ -638,7 +638,11 @@ export function buildProps(             }              // #10696 in case a v-bind object contains ref-            pushRefVForMarker()+            // (not for slot outlets: refs have no effect there and merging+            // would turn non-object slot props such as arrays into objects)+            if (node.tagType !== ElementTypes.SLOT) {+              pushRefVForMarker()+            }             pushMergeArg()             mergeArgs.push(exp)           } else {packages/compiler-core/src/utils.tsindex aa426bbab..3002fa433 100644@@ -445,6 +445,16 @@ export function injectProp(       props.properties.unshift(prop)     }     propsWithInjection = props+  } else if (node.type === NodeTypes.JS_CALL_EXPRESSION) {+    // <slot v-bind="expr">: merging would turn non-object values (e.g. arrays)+    // into objects, so the slot would receive different props than without+    // the injected key. Leave the props untouched and pass the key as the+    // dedicated 6th argument of renderSlot() instead.+    const args = node.arguments as CallExpression['arguments']+    if (args.length < 4) args[3] = `undefined` // fallback+    if (args.length < 5) args[4] = `undefined` // noSlotted+    args[5] = prop.value+    return   } else {     // single v-bind with expression, return a merged replacement     propsWithInjection = createCallExpression(context.helper(MERGE_PROPS), [packages/compiler-ssr/__tests__/ssrSlotOutlet.spec.tsindex 86863cfb8..c41689d08 100644@@ -46,6 +46,17 @@ describe('ssr: <slot>', () => {       `)   }) +  test('v-for + v-bind should pass props as-is', () => {+    const { code } = compile(+      `<template v-for="item in items" :key="item.id"><slot v-bind="item.list" /></template>`,+    )+    expect(code).not.toMatch(`mergeProps`)+    expect(code).not.toMatch(`ref_for`)+    expect(code).toMatch(+      `_ssrRenderSlot(_ctx.$slots, "default", item.list, null, _push, _parent)`,+    )+  })+   test('with fallback', () => {     expect(compile(`<slot>some {{ fallback }} content</slot>`).code)       .toMatchInlineSnapshot(`packages/runtime-core/src/helpers/renderSlot.tsindex 8f65f8af4..507deff3d 100644@@ -16,7 +16,7 @@ import {   isVNode,   openBlock, } from '../vnode'-import { PatchFlags, SlotFlags, isSymbol } from '@vue/shared'+import { PatchFlags, SlotFlags, extend, isSymbol } from '@vue/shared' import { warn } from '../warning' import { isAsyncWrapper } from '../apiAsyncComponent' @@ -32,13 +32,21 @@ export function renderSlot(   // the compiler and guaranteed to be a function returning an array   fallback?: () => VNodeArrayChildren,   noSlotted?: boolean,+  // branch / v-for key generated by the compiler when the slot props are a+  // single `v-bind="expr"` that must be passed to the slot as-is+  key?: PropertyKey, ): VNode {+  // props may be null when passed via `v-bind="expr"`+  if (!props) props = {}   if (     currentRenderingInstance!.ce ||     (currentRenderingInstance!.parent &&       isAsyncWrapper(currentRenderingInstance!.parent) &&       currentRenderingInstance!.parent.ce)   ) {+    // the compiler-injected key belongs on the <slot> vnode, as it did when+    // it was merged into the props (copy to avoid mutating user props)+    if (key != null) props = extend({ key }, props)     const hasProps = Object.keys(props).length > 0     // in custom element mode, render <slot/> as actual slot outlets     // wrap it with a fragment because in shadowRoot: false mode the slot@@ -80,6 +88,7 @@ export function renderSlot(     const validSlotContent = slot && ensureValidVNode(slot(props))     const slotKey =       props.key ||+      key ||       // slot content array of a dynamic conditional slot may have a branch       // key attached in the `createSlots` helper, respect that       (validSlotContent && (validSlotContent as any).key)packages/runtime-dom/__tests__/customElement.spec.tsindex a5bea20b8..452c73e60 100644@@ -915,6 +915,46 @@ describe('defineCustomElement', () => {         `<div><slot class="bar"></slot></div>`,       )     })++    test('render slot with compiler-injected key', async () => {+      const toggle = ref(true)+      const slotProps = { class: 'foo' }+      const E = defineCustomElement({+        render() {+          return [+            h(+              'div',+              null,+              renderSlot(+                this.$slots,+                'named',+                slotProps,+                undefined,+                undefined,+                toggle.value ? 0 : 1,+              ),+            ),+          ]+        },+      })+      customElements.define('my-el-slot-key', E)+      container.innerHTML = `<my-el-slot-key></my-el-slot-key>`+      const e = container.childNodes[0] as VueElement+      expect(e.shadowRoot!.innerHTML).toBe(+        `<div><slot class="foo" name="named"></slot></div>`,+      )+      const slotEl = e.shadowRoot!.querySelector('slot')++      toggle.value = false+      await nextTick()+      expect(e.shadowRoot!.innerHTML).toBe(+        `<div><slot class="foo" name="named"></slot></div>`,+      )+      // a different key replaces the <slot> element+      expect(e.shadowRoot!.querySelector('slot')).not.toBe(slotEl)+      // user-provided props are not mutated+      expect(slotProps).toEqual({ class: 'foo' })+    })   })    describe('provide/inject', () => {packages/vue/__tests__/index.spec.tsindex 6eeff41dd..eb7d05fde 100644@@ -1,5 +1,5 @@ import { EMPTY_ARR } from '@vue/shared'-import { createApp, nextTick, reactive, ref } from '../src'+import { createApp, nextTick, reactive, ref, shallowRef } from '../src'  describe('compiler + runtime integration', () => {   it('should support runtime template compilation', () => {@@ -311,4 +311,77 @@ describe('compiler + runtime integration', () => {     app.mount(root)     expect(root.innerHTML).toBe('<div>60000000100000111</div>')   })++  test('conditionally rendered <slot v-bind> should pass array props as-is', async () => {+    const container = document.createElement('div')+    const ok = ref(true)+    const Child = {+      setup() {+        return { ok, arr: ['a', 'b'] }+      },+      template: `<slot v-if="ok" v-bind="arr" /><slot v-else v-bind="arr" name="other" />`,+    }+    const App = {+      components: { Child },+      template: `+        <Child>+          <template #default="props">{{ Array.isArray(props) }}:<span v-for="i in props">{{ i }}</span></template>+          <template #other="props">{{ Array.isArray(props) }}|<i v-for="i in props">{{ i }}</i></template>+        </Child>+      `,+    }+    createApp(App).mount(container)+    expect(container.innerHTML).toBe(`true:<span>a</span><span>b</span>`)++    ok.value = false+    await nextTick()+    expect(container.innerHTML).toBe(`true|<i>a</i><i>b</i>`)+  })++  test('keyed <template v-for> + <slot v-bind> should pass array props as-is', async () => {+    const container = document.createElement('div')+    // shallowRef: reactive arrays are copied by guardReactiveProps regardless+    const items = shallowRef([+      { id: 1, list: ['a', 'b'] },+      { id: 2, list: ['c'] },+    ])+    const Child = {+      setup() {+        return { items }+      },+      template: `<template v-for="item in items" :key="item.id"><slot v-bind="item.list" /></template>`,+    }+    const App = {+      components: { Child },+      template: `+        <Child v-slot="props"><p>{{ Array.isArray(props) }}:<span v-for="i in props">{{ i }}</span></p></Child>+      `,+    }+    createApp(App).mount(container)+    expect(container.innerHTML).toBe(+      `<p>true:<span>a</span><span>b</span></p><p>true:<span>c</span></p>`,+    )++    // the key must still be applied: reordering moves the existing elements+    const first = container.querySelector('p')+    items.value = [items.value[1], items.value[0]]+    await nextTick()+    expect(container.innerHTML).toBe(+      `<p>true:<span>c</span></p><p>true:<span>a</span><span>b</span></p>`,+    )+    expect(container.querySelectorAll('p')[1]).toBe(first)+  })++  test('conditionally rendered <slot v-bind> with null should pass empty props', () => {+    const container = document.createElement('div')+    const Child = {+      template: `<slot v-if="true" v-bind="null" />`,+    }+    const App = {+      components: { Child },+      template: `<Child v-slot="{ a }">{{ a === undefined }}</Child>`,+    }+    createApp(App).mount(container)+    expect(container.innerHTML).toBe(`true`)+  }) }) 
Merged fix · PR #15051+255 −11
packages/compiler-core/__tests__/transforms/__snapshots__/transformElement.spec.ts.snapindex 3da778eb6..c07237de2 100644@@ -121,6 +121,20 @@ return function render(_ctx, _cache) { }" `; +exports[`compiler: v-for > codegen > template v-for key injection with single slot child 1`] = `+"const _Vue = Vue++return function render(_ctx, _cache) {+  with (_ctx) {+    const { renderList: _renderList, Fragment: _Fragment, openBlock: _openBlock, createElementBlock: _createElementBlock, renderSlot: _renderSlot } = _Vue++    return (_openBlock(true), _createElementBlock(_Fragment, null, _renderList(items, (item) => {+      return _renderSlot($slots, "default", {}, undefined, undefined, item.id)+    }), 128 /* KEYED_FRAGMENT */))+  }+}"+`;+ exports[`compiler: v-for > codegen > template v-for w/ <slot/> 1`] = ` "const _Vue = Vue packages/compiler-core/__tests__/transforms/__snapshots__/vFor.spec.ts.snapindex 3da778eb6..c07237de2 100644@@ -121,6 +121,20 @@ return function render(_ctx, _cache) { }" `; +exports[`compiler: v-for > codegen > template v-for key injection with single slot child 1`] = `+"const _Vue = Vue++return function render(_ctx, _cache) {+  with (_ctx) {+    const { renderList: _renderList, Fragment: _Fragment, openBlock: _openBlock, createElementBlock: _createElementBlock, renderSlot: _renderSlot } = _Vue++    return (_openBlock(true), _createElementBlock(_Fragment, null, _renderList(items, (item) => {+      return _renderSlot($slots, "default", {}, undefined, undefined, item.id)+    }), 128 /* KEYED_FRAGMENT */))+  }+}"+`;+ exports[`compiler: v-for > codegen > template v-for w/ <slot/> 1`] = ` "const _Vue = Vue packages/compiler-core/__tests__/transforms/__snapshots__/vIf.spec.ts.snapindex 65ee73c46..ed2c8e540 100644@@ -80,7 +80,7 @@ return function render(_ctx, _cache) {     const { renderSlot: _renderSlot, createCommentVNode: _createCommentVNode } = _Vue      return ok-      ? _renderSlot($slots, "default", { key: 0 })+      ? _renderSlot($slots, "default", {}, undefined, undefined, 0)       : _createCommentVNode("v-if", true)   } }"@@ -140,7 +140,21 @@ return function render(_ctx, _cache) {     const { renderSlot: _renderSlot, createCommentVNode: _createCommentVNode } = _Vue      return ok-      ? _renderSlot($slots, "default", { key: 0 })+      ? _renderSlot($slots, "default", {}, undefined, undefined, 0)+      : _createCommentVNode("v-if", true)+  }+}"+`;++exports[`compiler: v-if > codegen > v-if on <slot/> with v-bind 1`] = `+"const _Vue = Vue++return function render(_ctx, _cache) {+  with (_ctx) {+    const { normalizeProps: _normalizeProps, guardReactiveProps: _guardReactiveProps, renderSlot: _renderSlot, createCommentVNode: _createCommentVNode } = _Vue++    return ok+      ? _renderSlot($slots, "default", _normalizeProps(_guardReactiveProps(items)), undefined, undefined, 0)       : _createCommentVNode("v-if", true)   } }"packages/compiler-core/__tests__/transforms/vFor.spec.tsindex 34991445c..839d9d358 100644@@ -918,6 +918,34 @@ describe('compiler: v-for', () => {       expect(generate(root).code).toMatchSnapshot()     }) +    test('template v-for key injection with single slot child', () => {+      const {+        root,+        node: { codegenNode },+      } = parseWithForTransform(+        '<template v-for="item in items" :key="item.id"><slot/></template>',+      )+      expect(+        assertSharedCodegen(codegenNode, true, true /* custom return */),+      ).toMatchObject({+        source: { content: `items` },+        params: [{ content: `item` }],+        returns: {+          type: NodeTypes.JS_CALL_EXPRESSION,+          callee: RENDER_SLOT,+          arguments: [+            '$slots',+            '"default"',+            '{}',+            'undefined',+            'undefined',+            { content: 'item.id' },+          ],+        },+      })+      expect(generate(root).code).toMatchSnapshot()+    })+     // #1907     test('template v-for key injection with single child', () => {       const {packages/compiler-core/__tests__/transforms/vIf.spec.tsindex fe3aef714..677f6b55b 100644@@ -3,6 +3,7 @@ import { transform } from '../../src/transform' import { transformIf } from '../../src/transforms/vIf' import { transformElement } from '../../src/transforms/transformElement' import { transformSlotOutlet } from '../../src/transforms/transformSlotOutlet'+import { transformBind } from '../../src/transforms/vBind' import {   type CommentNode,   type ConditionalExpression,@@ -509,7 +510,14 @@ describe('compiler: v-if', () => {       expect(codegenNode.consequent).toMatchObject({         type: NodeTypes.JS_CALL_EXPRESSION,         callee: RENDER_SLOT,-        arguments: ['$slots', '"default"', createObjectMatcher({ key: `[0]` })],+        arguments: [+          '$slots',+          '"default"',+          '{}',+          'undefined',+          'undefined',+          { content: '0' },+        ],       })       expect(generate(root).code).toMatchSnapshot()     })@@ -522,7 +530,41 @@ describe('compiler: v-if', () => {       expect(codegenNode.consequent).toMatchObject({         type: NodeTypes.JS_CALL_EXPRESSION,         callee: RENDER_SLOT,-        arguments: ['$slots', '"default"', createObjectMatcher({ key: `[0]` })],+        arguments: [+          '$slots',+          '"default"',+          '{}',+          'undefined',+          'undefined',+          { content: '0' },+        ],+      })+      expect(generate(root).code).toMatchSnapshot()+    })++    test('v-if on <slot/> with v-bind', () => {+      const {+        root,+        node: { codegenNode },+      } = parseWithIfTransform(`<slot v-if="ok" v-bind="items"></slot>`, {+        directiveTransforms: {+          bind: transformBind,+        },+      })+      expect(codegenNode.consequent).toMatchObject({+        type: NodeTypes.JS_CALL_EXPRESSION,+        callee: RENDER_SLOT,+        arguments: [+          '$slots',+          '"default"',+          {+            type: NodeTypes.JS_CALL_EXPRESSION,+            callee: NORMALIZE_PROPS,+          },+          'undefined',+          'undefined',+          { content: '0' },+        ],       })       expect(generate(root).code).toMatchSnapshot()     })packages/compiler-core/src/ast.tsindex e3cc5304d..e6da01edb 100644@@ -488,14 +488,29 @@ export interface DirectiveArgumentNode extends ArrayExpression { export interface RenderSlotCall extends CallExpression {   callee: typeof RENDER_SLOT   arguments:-    // $slots, name, props, fallback+    // $slots, name, props, fallback, noSlotted, branchKey     | [string, string | ExpressionNode]-    | [string, string | ExpressionNode, PropsExpression]+    | [string, string | ExpressionNode, PropsExpression | '{}']     | [         string,         string | ExpressionNode,         PropsExpression | '{}',-        TemplateChildNode[],+        FunctionExpression | string,+      ]+    | [+        string,+        string | ExpressionNode,+        PropsExpression | '{}',+        FunctionExpression | string,+        string,+      ]+    | [+        string,+        string | ExpressionNode,+        PropsExpression | '{}',+        FunctionExpression | string,+        string,+        JSChildNode,       ] } packages/compiler-core/src/utils.tsindex aa426bbab..025f6c32d 100644@@ -392,6 +392,10 @@ export function injectProp(   prop: Property,   context: TransformContext, ): void {+  if (node.type !== NodeTypes.VNODE_CALL && injectSlotKey(node, prop)) {+    return+  }+   let propsWithInjection: ObjectExpression | CallExpression | undefined   /**    * 1. mergeProps(...)@@ -473,6 +477,36 @@ export function injectProp(   } } +function injectSlotKey(node: RenderSlotCall, prop: Property): boolean {+  if (+    prop.key.type !== NodeTypes.SIMPLE_EXPRESSION ||+    prop.key.content !== 'key'+  ) {+    return false+  }++  // If the slot already has a user-provided key, avoid injecting the branch+  // key so the user key keeps its existing priority.+  const props = node.arguments[2]+  if (props && !isString(props)) {+    const [unnormalizedProps] = getUnnormalizedProps(props as PropsExpression)+    if (+      unnormalizedProps &&+      !isString(unnormalizedProps) &&+      unnormalizedProps.type === NodeTypes.JS_OBJECT_EXPRESSION &&+      hasProp(prop, unnormalizedProps)+    ) {+      return true+    }+  }++  node.arguments[2] ||= '{}'+  node.arguments[3] ||= 'undefined'+  node.arguments[4] ||= 'undefined'+  node.arguments[5] = prop.value+  return true+}+ // check existing key to avoid overriding user provided keys function hasProp(prop: Property, props: ObjectExpression) {   let result = falsepackages/runtime-core/__tests__/helpers/renderSlot.spec.tsindex bc0678b51..f359f431c 100644@@ -38,6 +38,83 @@ describe('renderSlot', () => {     expect(vnode.key).toBe('_default')   }) +  it('should allow symbol values for compiler-injected slot keys', () => {+    const key = Symbol()+    const vnode = renderSlot(+      { default: () => [h('div')] },+      'default',+      {},+      undefined,+      undefined,+      key,+    )+    expect(vnode.key).toBe('_default')+  })++  it('should not expose compiler-injected slot keys to slot props', () => {+    let receivedProps: any+    const props = ['foo', 'bar']+    const vnode = renderSlot(+      {+        default: props => {+          receivedProps = props+          return [h('div')]+        },+      },+      'default',+      props as any,+      undefined,+      undefined,+      'branch',+    )++    expect(receivedProps).toBe(props)+    expect(receivedProps).not.toHaveProperty('key')+    expect(vnode.key).toBe('branch')+  })++  it('should prefer user-provided slot prop keys over compiler-injected keys', () => {+    let receivedProps: any+    const props = { key: 'user' }+    const vnode = renderSlot(+      {+        default: props => {+          receivedProps = props+          return [h('div')]+        },+      },+      'default',+      props,+      undefined,+      undefined,+      'branch',+    )++    expect(receivedProps).toBe(props)+    expect(vnode.key).toBe('user')+  })++  it('should preserve compiler-injected slot keys in custom element mode', () => {+    setCurrentRenderingInstance({ type: {}, ce: {} } as any)++    let vnode = renderSlot({}, 'default', {}, undefined, undefined, 0)+    let slot = (vnode.children as any[])[0]+    expect(slot.type).toBe('slot')+    expect(slot.key).toBe(0)+    expect(vnode.patchFlag).toBe(PatchFlags.BAIL)++    vnode = renderSlot(+      {},+      'default',+      { key: 'user' },+      undefined,+      undefined,+      'branch',+    )+    slot = (vnode.children as any[])[0]+    expect(slot.key).toBe('user')+  })+   it('should render slot fallback', () => {     const vnode = renderSlot({}, 'default', { key: 'foo' }, () => ['fallback'])     expect(vnode.children).toEqual(['fallback'])packages/runtime-core/src/helpers/renderSlot.tsindex 8f65f8af4..2a68ee3e4 100644@@ -16,7 +16,7 @@ import {   isVNode,   openBlock, } from '../vnode'-import { PatchFlags, SlotFlags, isSymbol } from '@vue/shared'+import { PatchFlags, SlotFlags, extend, isSymbol } from '@vue/shared' import { warn } from '../warning' import { isAsyncWrapper } from '../apiAsyncComponent' @@ -32,6 +32,7 @@ export function renderSlot(   // the compiler and guaranteed to be a function returning an array   fallback?: () => VNodeArrayChildren,   noSlotted?: boolean,+  branchKey?: PropertyKey, ): VNode {   if (     currentRenderingInstance!.ce ||@@ -39,17 +40,21 @@ export function renderSlot(       isAsyncWrapper(currentRenderingInstance!.parent) &&       currentRenderingInstance!.parent.ce)   ) {-    const hasProps = Object.keys(props).length > 0+    const slotProps =+      branchKey != null && props.key == null+        ? extend({}, props, { key: branchKey })+        : props+    const hasProps = Object.keys(slotProps).length > 0     // in custom element mode, render <slot/> as actual slot outlets     // wrap it with a fragment because in shadowRoot: false mode the slot     // element gets replaced by injected content-    if (name !== 'default') props.name = name+    if (name !== 'default') slotProps.name = name     return (       openBlock(),       createBlock(         Fragment,         null,-        [createVNode('slot', props, fallback && fallback())],+        [createVNode('slot', slotProps, fallback && fallback())],         hasProps ? PatchFlags.BAIL : PatchFlags.STABLE_FRAGMENT,       )     )@@ -80,6 +85,7 @@ export function renderSlot(     const validSlotContent = slot && ensureValidVNode(slot(props))     const slotKey =       props.key ||+      branchKey ||       // slot content array of a dynamic conditional slot may have a branch       // key attached in the `createSlots` helper, respect that       (validSlotContent && (validSlotContent as any).key)