Skip to content

fix(runtime-dom): apply css vars to a vapor slot rendered in vdom - #15575

Merged
edison1105 merged 3 commits into
vuejs:minorfrom
ValentinYoushkevich:fix/vapor-css-vars-slot
Sep 20, 2026
Merged

edison1105 merged 3 commits into
vuejs:minorfrom
ValentinYoushkevich:fix/vapor-css-vars-slot

Conversation

@ValentinYoushkevich

@ValentinYoushkevich ValentinYoushkevich commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

A vdom component whose root is <slot/> and that declares css variables with v-bind() leaves slot content coming from a vapor parent unstyled. Under a vdom parent the same component styles it (playground — the box in the right column is green, the one in the left has no background).

setVarsOnVNode handles element, fragment, static and component vnodes, and a VaporSlot vnode falls through all of them. Its block sits on vnode.vb. I hand it to the vapor side through the interop interface, the same line move already uses there, since setVarsOnBlock is not reachable from runtime-dom.

The variables are written when they are applied and re-applied by the existing MutationObserver, so a slot block that re-renders on its own is not re-registered. Same limitation as the vapor branch that is already there.

A vdom component whose root is `<slot/>` renders a `VaporSlot` vnode when
the slot content comes from a vapor parent. `setVarsOnVNode` has no branch
for it, so the component's own `v-bind()` css vars never reach that content
- pure vdom applies them.

Route the write through the interop, which resolves the slot's block from
`vnode.vb` the same way the interop `move` already does.
@coderabbitai

coderabbitai Bot commented Sep 19, 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: e131172d-7aa9-4347-a80d-81a3e1c72535

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

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.

@netlify

netlify Bot commented Sep 19, 2026

Copy link
Copy Markdown

❌ Deploy Preview for vue-sfc-playground failed. Why did it fail? →

Name Link
🔨 Latest commit 0acc219
🔍 Latest deploy log https://app.netlify.com/projects/vue-sfc-playground/deploys/6aaea3a384491500087f758e

runtime-core trims its vapor exports for every format other than vapor and
esm-bundler, so `VaporSlot` is not importable from runtime-dom and the
global / cjs / esm-browser builds failed to resolve it. `vb` is only ever
set on those vnodes, so the branch condition is equivalent.
@pkg-pr-new

pkg-pr-new Bot commented Sep 19, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@vue/compiler-core

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

@vue/compiler-dom

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

@vue/compiler-sfc

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

@vue/compiler-ssr

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

@vue/compiler-vapor

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

@vue/reactivity

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

@vue/runtime-core

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

@vue/runtime-dom

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

@vue/runtime-vapor

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

@vue/server-renderer

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

@vue/shared

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

vue

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

@vue/compat

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

commit: 63f0166

@github-actions

github-actions Bot commented Sep 19, 2026 •

Copy link
Copy Markdown

Size Report

Bundles

File Size Gzip Brotli
compiler-dom.global.prod.js 87.2 kB 30.6 kB 26.9 kB
runtime-dom.global.prod.js 117 kB (+54 B) 44 kB (+11 B) 39.5 kB (+103 B)
vue.global.prod.js 177 kB (+54 B) 64.1 kB (+12 B) 57.1 kB (+19 B)

Usages

Name Size Gzip Brotli
createApp (CAPI only) 53.8 kB 20.8 kB 19 kB
createApp 62.5 kB 24 kB 21.9 kB
createApp + vaporInteropPlugin 122 kB (+6 B) 43.9 kB (+1 B) 39.5 kB (+45 B)
createVaporApp 30.8 kB 11.8 kB 10.9 kB
createSSRApp 67.7 kB 26.1 kB 23.7 kB
createVaporSSRApp 37.2 kB 14.1 kB 12.9 kB
defineCustomElement 69.1 kB 26 kB 23.7 kB
defineVaporCustomElement 46.2 kB 16.8 kB 15.4 kB
overall 78.1 kB 29.6 kB 26.8 kB

@edison1105 edison1105 added the scope: vapor related to vapor mode label Sep 20, 2026
@edison1105

Copy link
Copy Markdown
Member

Thanks for the fix! The approach looks good to me. A couple of small suggestions:

Could we preserve the existing component path and reuse getVaporInstance()?

setVarsOnBlock(vnode.vb || getVaporInstance(vnode).block, vars)

This avoids another any cast and the extra component check and recursive call inside setVarsOnBlock().

For the first test, could we toggle data.value.ok = true without changing color, assert that #b receives red, and then update data.value.color separately? Replacing the whole object also retriggers the CSS vars watcher, so the current test doesn't verify that independently changing slot content receives the existing variables.

@ValentinYoushkevich

Copy link
Copy Markdown
Contributor Author

Both done, thanks — getVaporInstance(vnode).block reads better and drops the duplicate cast.

You were right about the test: replacing the whole object hid what it was meant to prove. It now toggles ok on its own and asserts #b picks up the existing red, then changes color separately. Both tests still fail without the fix.

@edison1105
edison1105 merged commit a4bcb1d into vuejs:minor Sep 20, 2026
15 checks passed
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 wait changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants