Skip to content

fix(compiler-dom): correctly stringify 0 and false in v-html - #15571

Open
patienry wants to merge 2 commits into
vuejs:mainfrom
patienry:fix/v-html
Open

patienry wants to merge 2 commits into
vuejs:mainfrom
patienry:fix/v-html

Conversation

@patienry

@patienry patienry commented Sep 18, 2026

Copy link
Copy Markdown

Reproduction link

In the third scenario in the reproduction link, 0 is not rendered correctly, which is inconsistent with the rendering behavior in the other scenarios.

Summary by CodeRabbit

  • Bug Fixes
    • Fixed static template generation for v-html when values are empty strings or null.
    • v-html content now consistently takes precedence over fallback element content.
    • Preserved falsy literal values such as 0 and false as rendered element text.

@coderabbitai

coderabbitai Bot commented Sep 18, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: cc069de9-9bd3-4b0a-9b6a-d1f336854fe0

📥 Commits

Reviewing files that changed from the base of the PR and between 4ecdfa3 and d5293f4.

📒 Files selected for processing (1)
  • packages/compiler-dom/src/transforms/stringifyStatic.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

The static stringifier now distinguishes absent directive content from empty content. Empty and null v-html results suppress child rendering. Tests cover repeated falsy v-html values.

Changes

Static directive handling

Layer / File(s) Summary
Directive presence and output handling
packages/compiler-dom/src/transforms/stringifyStatic.ts, packages/compiler-dom/__tests__/transforms/stringifyStatic.spec.ts
stringifyElement uses undefined to represent absent directive content. v-html converts null results to empty strings and preserves empty output. Tests cover repeated v-html values of '0' and 'false'.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: edison1105

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: correcting compiler-dom serialization of 0 and false in v-html.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

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.

@edison1105 edison1105 added 🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage. scope: compiler labels Sep 21, 2026
@pkg-pr-new

pkg-pr-new Bot commented Sep 21, 2026

Copy link
Copy Markdown

Open in StackBlitz

@vue/compiler-core

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

@vue/compiler-dom

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

@vue/compiler-sfc

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

@vue/compiler-ssr

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

@vue/reactivity

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

@vue/runtime-core

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

@vue/runtime-dom

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

@vue/server-renderer

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

@vue/shared

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

vue

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

@vue/compat

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

commit: d5293f4

@github-actions

Copy link
Copy Markdown

Size Report

Bundles

File Size Gzip Brotli
runtime-dom.global.prod.js 109 kB 41.3 kB 37 kB
vue.global.prod.js 168 kB 61.5 kB 54.6 kB

Usages

Name Size Gzip Brotli
createApp (CAPI only) 50.8 kB 19.6 kB 18 kB
createApp 58.9 kB 22.7 kB 20.8 kB
createSSRApp 63.7 kB 24.7 kB 22.5 kB
defineCustomElement 65.2 kB 24.6 kB 22.5 kB
overall 73.5 kB 28 kB 25.5 kB

Comment thread packages/compiler-dom/src/transforms/stringifyStatic.ts Outdated
@patienry
patienry requested a review from edison1105 September 21, 2026 01:18
@edison1105 edison1105 added ready to merge The PR is ready to be merged. and removed wait changes labels Sep 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage. ready to merge The PR is ready to be merged. scope: compiler

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants