Skip to content

fix(vapor): support ref in v-bind object - #15900

Closed
meta-syntax wants to merge 2 commits into
vuejs:minorfrom
meta-syntax:fix/runtime-vapor-v-bind-object-ref
Closed

meta-syntax wants to merge 2 commits into
vuejs:minorfrom
meta-syntax:fix/runtime-vapor-v-bind-object-ref

Conversation

@meta-syntax

Copy link
Copy Markdown

Ports the fix of #10696 (#10706) to Vapor.

In Vapor, a ref inside a v-bind object is dropped, so useTemplateRef('r') stays null for both elements and components:

<div v-bind="{ ref: 'r' }" />
<Child v-bind="{ ref: 'r' }" />
<div v-for="i in 2" v-bind="{ ref: 'r' }" />

In VDOM, these set the template ref, and inside v-for the ref becomes an array.

Changes

  • Elements: patchDynamicProps passes the ref of the merged props to the template ref setter before skipping reserved keys. Like VDOM, the compiler adds { ref_for: true } to the props of an element with v-bind="obj" inside v-for.
  • Components: for a component with v-bind="obj" and no ref attribute, the compiler emits setComponentPropsRef(n0, refFor) after createComponent, at the same place as setStaticTemplateRef. It reads ref from the inputs delivered to the component.

Trade-offs

  • Inside v-for, setDynamicProps now receives two sources for an element with v-bind="obj", so it merges them on each update. VDOM adds the same marker.
  • A component with a dynamic v-bind object gets one more render effect. With constant inputs, the ref is set once without an effect.

Not covered

  • <component :is> with a ref inside v-bind: the dynamic component renders a fragment, and this PR leaves it unchanged.

The added tests fail without the fix.

@coderabbitai

coderabbitai Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 3928410e-a7f2-43d3-8ac6-96ef3dfb148a

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pkg-pr-new

pkg-pr-new Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@vue/compiler-core

pnpm add https://pkg.pr.new/@vue/compiler-core@15900
npm i https://pkg.pr.new/@vue/compiler-core@15900
yarn add https://pkg.pr.new/@vue/[email protected]

@vue/compiler-dom

pnpm add https://pkg.pr.new/@vue/compiler-dom@15900
npm i https://pkg.pr.new/@vue/compiler-dom@15900
yarn add https://pkg.pr.new/@vue/[email protected]

@vue/compiler-sfc

pnpm add https://pkg.pr.new/@vue/compiler-sfc@15900
npm i https://pkg.pr.new/@vue/compiler-sfc@15900
yarn add https://pkg.pr.new/@vue/[email protected]

@vue/compiler-ssr

pnpm add https://pkg.pr.new/@vue/compiler-ssr@15900
npm i https://pkg.pr.new/@vue/compiler-ssr@15900
yarn add https://pkg.pr.new/@vue/[email protected]

@vue/compiler-vapor

pnpm add https://pkg.pr.new/@vue/compiler-vapor@15900
npm i https://pkg.pr.new/@vue/compiler-vapor@15900
yarn add https://pkg.pr.new/@vue/[email protected]

@vue/reactivity

pnpm add https://pkg.pr.new/@vue/reactivity@15900
npm i https://pkg.pr.new/@vue/reactivity@15900
yarn add https://pkg.pr.new/@vue/[email protected]

@vue/runtime-core

pnpm add https://pkg.pr.new/@vue/runtime-core@15900
npm i https://pkg.pr.new/@vue/runtime-core@15900
yarn add https://pkg.pr.new/@vue/[email protected]

@vue/runtime-dom

pnpm add https://pkg.pr.new/@vue/runtime-dom@15900
npm i https://pkg.pr.new/@vue/runtime-dom@15900
yarn add https://pkg.pr.new/@vue/[email protected]

@vue/runtime-vapor

pnpm add https://pkg.pr.new/@vue/runtime-vapor@15900
npm i https://pkg.pr.new/@vue/runtime-vapor@15900
yarn add https://pkg.pr.new/@vue/[email protected]

@vue/server-renderer

pnpm add https://pkg.pr.new/@vue/server-renderer@15900
npm i https://pkg.pr.new/@vue/server-renderer@15900
yarn add https://pkg.pr.new/@vue/[email protected]

@vue/shared

pnpm add https://pkg.pr.new/@vue/shared@15900
npm i https://pkg.pr.new/@vue/shared@15900
yarn add https://pkg.pr.new/@vue/[email protected]

vue

pnpm add https://pkg.pr.new/vue@15900
npm i https://pkg.pr.new/vue@15900
yarn add https://pkg.pr.new/[email protected]

@vue/compat

pnpm add https://pkg.pr.new/@vue/compat@15900
npm i https://pkg.pr.new/@vue/compat@15900
yarn add https://pkg.pr.new/@vue/[email protected]

commit: e0601e9

@github-actions

Copy link
Copy Markdown

Size Report

Bundles

File Size Gzip Brotli
compiler-dom.global.prod.js 87.4 kB 30.7 kB 27 kB
runtime-dom.global.prod.js 119 kB 44.8 kB 40.2 kB
vue.global.prod.js 180 kB 65.1 kB 58 kB

Usages

Name Size Gzip Brotli
createApp (CAPI only) 54.6 kB 21.2 kB 19.4 kB
createApp 63.5 kB 24.5 kB 22.2 kB
createApp + vaporInteropPlugin 140 kB (+2.17 kB) 50.8 kB (+852 B) 45.5 kB (+683 B)
createVaporApp 36.4 kB (+2.2 kB) 14.1 kB (+844 B) 12.9 kB (+775 B)
createSSRApp 68.6 kB 26.5 kB 24.1 kB
createVaporSSRApp 43.2 kB (+2.21 kB) 16.5 kB (+866 B) 15.2 kB (+822 B)
defineCustomElement 70.1 kB 26.5 kB 24.1 kB
defineVaporCustomElement 51.3 kB (+2.2 kB) 18.9 kB (+845 B) 17.3 kB (+764 B)
overall 79.1 kB 30.1 kB 27.2 kB

@edison1105 edison1105 added the scope: vapor related to vapor mode label Oct 16, 2026
@edison1105

Copy link
Copy Markdown
Member

Thanks for the PR, but we're going to treat this as an intentional Vapor limitation rather than fix it.

In Vapor, template refs are a compile-time construct: the compiler emits the ref binding only for an explicit ref / :ref attribute. A ref key inside a v-bind="obj" object (or a dynamic :[name]) is only known at runtime, so supporting it means either emitting a ref setter for every v-bind element/component, or adding per-element owner/context bookkeeping and a ref_for merge on the dynamic-props path. Neither is worth it for this usage, so Vapor requires the ref to be declared explicitly.

Closing as won't fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope: vapor related to vapor mode

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants