Skip to content

fix(runtime-dom): keep injected css vars when style binding becomes nullish - #15623

Merged
edison1105 merged 1 commit into
vuejs:minorfrom
ValentinYoushkevich:fix/dom-style-null-css-vars-2
Sep 24, 2026
Merged

edison1105 merged 1 commit into
vuejs:minorfrom
ValentinYoushkevich:fix/dom-style-null-css-vars-2

Conversation

@ValentinYoushkevich

Copy link
Copy Markdown
Contributor

When a :style binding goes from an object to null or undefined, patchStyle removes the whole style attribute. That also wipes the variables v-bind() in <style> put on the element, and nothing puts them back until the owner re-renders or the variables change.

The easy way to hit it is v-bind() in a parent and a nullable :style on the root of a child that re-renders on its own (playground). In Vapor it also happens when both are in the same component.

The string branch already keeps these variables (#9824). This does the same for the nullish case and writes the stored variable text back instead of removing the attribute. This changes VDOM too: there the variable used to disappear, and now it stays.

@coderabbitai

coderabbitai Bot commented Sep 24, 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: 2ca16e0a-e085-4589-900d-db63f776b4db

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.

@pkg-pr-new

pkg-pr-new Bot commented Sep 24, 2026

Copy link
Copy Markdown

Open in StackBlitz

@vue/compiler-core

pnpm add https://pkg.pr.new/@vue/compiler-core@15623
npm i https://pkg.pr.new/@vue/compiler-core@15623
yarn add https://pkg.pr.new/@vue/compiler-core@15623.tgz

@vue/compiler-dom

pnpm add https://pkg.pr.new/@vue/compiler-dom@15623
npm i https://pkg.pr.new/@vue/compiler-dom@15623
yarn add https://pkg.pr.new/@vue/compiler-dom@15623.tgz

@vue/compiler-sfc

pnpm add https://pkg.pr.new/@vue/compiler-sfc@15623
npm i https://pkg.pr.new/@vue/compiler-sfc@15623
yarn add https://pkg.pr.new/@vue/compiler-sfc@15623.tgz

@vue/compiler-ssr

pnpm add https://pkg.pr.new/@vue/compiler-ssr@15623
npm i https://pkg.pr.new/@vue/compiler-ssr@15623
yarn add https://pkg.pr.new/@vue/compiler-ssr@15623.tgz

@vue/compiler-vapor

pnpm add https://pkg.pr.new/@vue/compiler-vapor@15623
npm i https://pkg.pr.new/@vue/compiler-vapor@15623
yarn add https://pkg.pr.new/@vue/compiler-vapor@15623.tgz

@vue/reactivity

pnpm add https://pkg.pr.new/@vue/reactivity@15623
npm i https://pkg.pr.new/@vue/reactivity@15623
yarn add https://pkg.pr.new/@vue/reactivity@15623.tgz

@vue/runtime-core

pnpm add https://pkg.pr.new/@vue/runtime-core@15623
npm i https://pkg.pr.new/@vue/runtime-core@15623
yarn add https://pkg.pr.new/@vue/runtime-core@15623.tgz

@vue/runtime-dom

pnpm add https://pkg.pr.new/@vue/runtime-dom@15623
npm i https://pkg.pr.new/@vue/runtime-dom@15623
yarn add https://pkg.pr.new/@vue/runtime-dom@15623.tgz

@vue/runtime-vapor

pnpm add https://pkg.pr.new/@vue/runtime-vapor@15623
npm i https://pkg.pr.new/@vue/runtime-vapor@15623
yarn add https://pkg.pr.new/@vue/runtime-vapor@15623.tgz

@vue/server-renderer

pnpm add https://pkg.pr.new/@vue/server-renderer@15623
npm i https://pkg.pr.new/@vue/server-renderer@15623
yarn add https://pkg.pr.new/@vue/server-renderer@15623.tgz

@vue/shared

pnpm add https://pkg.pr.new/@vue/shared@15623
npm i https://pkg.pr.new/@vue/shared@15623
yarn add https://pkg.pr.new/@vue/shared@15623.tgz

vue

pnpm add https://pkg.pr.new/vue@15623
npm i https://pkg.pr.new/vue@15623
yarn add https://pkg.pr.new/vue@15623.tgz

@vue/compat

pnpm add https://pkg.pr.new/@vue/compat@15623
npm i https://pkg.pr.new/@vue/compat@15623
yarn add https://pkg.pr.new/@vue/compat@15623.tgz

commit: 4b50cd9

@github-actions

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 116 kB (+29 B) 43.8 kB (+8 B) 39.3 kB (+26 B)
vue.global.prod.js 176 kB (+29 B) 64 kB (+13 B) 57.1 kB (+78 B)

Usages

Name Size Gzip Brotli
createApp (CAPI only) 53.1 kB (+29 B) 20.7 kB (+12 B) 18.9 kB (-50 B)
createApp 61.9 kB (+29 B) 23.9 kB (+11 B) 21.7 kB (-5 B)
createApp + vaporInteropPlugin 124 kB (+29 B) 44.8 kB (+12 B) 40.3 kB (-29 B)
createVaporApp 30.9 kB (+29 B) 11.9 kB (+11 B) 10.9 kB (+4 B)
createSSRApp 66.9 kB (+29 B) 25.9 kB (+10 B) 23.6 kB
createVaporSSRApp 37.6 kB (+29 B) 14.3 kB (+9 B) 13.1 kB (-1 B)
defineCustomElement 68.4 kB (+29 B) 25.9 kB (+11 B) 23.5 kB (-28 B)
defineVaporCustomElement 46.3 kB (+29 B) 16.9 kB (+9 B) 15.4 kB (+12 B)
overall 77.4 kB (+29 B) 29.4 kB (+10 B) 26.7 kB (+15 B)

@ValentinYoushkevich

Copy link
Copy Markdown
Contributor Author

For context, this is the same bug as #9821 (fixed for string styles in #9824), just in the nullish branch. For example, a wrapper that themes a library component with v-bind() in its <style>, while the library's root uses :style="cond ? { ... } : undefined": the wrapper's CSS variables are dropped on the child's next update.

@edison1105
edison1105 merged commit d9abcb8 into vuejs:minor Sep 24, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants