Skip to content

fix(runtime-dom): restore v-show display after hydration - #16548

Merged
edison1105 merged 1 commit into
mainfrom
edison/fix/vshow-hydration-display
Dec 3, 2026
Merged

edison1105 merged 1 commit into
mainfrom
edison/fix/vshow-hydration-display

Conversation

@edison1105

@edison1105 edison1105 commented Dec 3, 2026 •

Copy link
Copy Markdown
Member

close #16544

Summary by CodeRabbit

  • Bug Fixes
    • Fixed hydration behavior so elements controlled by v-show correctly restore their intended display style when shown, including styles provided as strings, objects, or arrays and values marked !important.
    • Fixed elements hidden during hydration to return to their authored display style when shown, rather than retaining an incorrect display value.

@edison1105 edison1105 added 🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage. scope:hydration labels Dec 3, 2026
@coderabbitai

coderabbitai Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

When v-show hydrates an element whose display is none, it now resolves the original display from the vnode style. Hydration tests cover string, object, !important, and array styles.

Changes: Hydration display restoration

Layer / File(s) Summary
Resolve and test the authored display
packages/runtime-dom/src/directives/vShow.ts, packages/runtime-core/__tests__/hydration.spec.ts
beforeMount passes the vnode to the display resolver. If the element is hidden and the vnode has a style, the resolver applies that style to a reusable scratch element and reads its display. Tests cover string, object, !important, and array styles.

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

Change: Bug fix · Severity of issue fixed: Low

Possibly related PRs

  • vuejs/core#16544: Addresses the same hydration display restoration behavior and covers overlapping style forms.

Suggested reviewers: yyx990803, sxzz

Merge Risk: Minimal · up to d63ac

This change restores the authored display value when a server-rendered v-show element hidden at hydration becomes visible. The change is narrow and has hydration test coverage for the main style forms. No merge-blocking risk was identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the change: it fixes v-show display restoration after hydration in runtime-dom. The changeset modifies vShow.ts beforeMount to resolve the original display from vnode style, and adds h…
Linked Issues check Passed [#16544] requires restoring the authored CSS display after hydration for v-show elements hidden by SSR. The reviewed diff in packages/runtime-dom/src/directives/vShow.ts changes beforeMount to call re…
Out of Scope Changes check Passed Compared with the merge base 4d464dc, the reviewed head changes only vShow.ts (import of VNode and patchStyle, the beforeMount change, and the new resolveOriginalDisplay helper with a module-level scr…
Full details: Title check

Explanation

The title names the change: it fixes v-show display restoration after hydration in runtime-dom. The changeset modifies vShow.ts beforeMount to resolve the original display from vnode style, and adds hydration tests for v-show display restoration. The title matches the main change and is specific enough for a reader scanning history.

Full details: Linked Issues check

Explanation

[#16544] requires restoring the authored CSS display after hydration for v-show elements hidden by SSR. The reviewed diff in packages/runtime-dom/src/directives/vShow.ts changes beforeMount to call resolveOriginalDisplay(el, vnode). When el.style.display is 'none' and vnode.props.style exists, that function applies the client style to a scratch div with patchStyle and reads the resulting display. This covers string, object, array, and !important styles, because patchStyle handles them. If the resolved display is still 'none', the function returns '' as before, so the authored display 'none' case keeps the previous behavior. Client-only mounts are not affected, because their style is patched before the hook runs. The raw summary reports five hydration tests in packages/runtime-core/tests/hydration.spec.ts covering string, !important, hoisted object, and array styles, plus the hide-again case. These cover the four tests requested by the issue. I did not run the tests. The test coverage rests on the summary, and the reported test results are not independently verified.

Full details: Out of Scope Changes check

Explanation

Compared with the merge base 4d464dc, the reviewed head changes only vShow.ts (import of VNode and patchStyle, the beforeMount change, and the new resolveOriginalDisplay helper with a module-level scratch element) and hydration.spec.ts tests. All changes connect directly to the v-show hydration fix in #16544. The helper reuses existing patchStyle logic rather than adding a new injection path. No public API declarations changed according to the summary. No unrelated changes were found in the reviewed evidence.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • 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

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 6a3206a6-6359-40ed-9f3e-b94dca475915
Commits

Reviewing files that changed from the base of the PR and between 4d464dc and d63aca5.

Files selected for processing: 2

  • packages/runtime-core/__tests__/hydration.spec.ts
  • packages/runtime-dom/src/directives/vShow.ts

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

@pkg-pr-new

pkg-pr-new Bot commented Dec 3, 2026

Copy link
Copy Markdown

Open in StackBlitz

@vue/compiler-core

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

@vue/compiler-dom

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

@vue/compiler-sfc

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

@vue/compiler-ssr

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

@vue/reactivity

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

@vue/runtime-core

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

@vue/runtime-dom

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

@vue/server-renderer

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

@vue/shared

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

vue

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

@vue/compat

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

commit: d63aca5

@github-actions

github-actions Bot commented Dec 3, 2026

Copy link
Copy Markdown

Size Report

Bundles

File Size Gzip Brotli
runtime-dom.global.prod.js 116 kB (+167 B) 43.4 kB (+58 B) 38.9 kB (-8 B)
vue.global.prod.js 175 kB (+163 B) 63.9 kB (+79 B) 56.6 kB (-28 B)

Usages

Name Size Gzip Brotli
createApp (CAPI only) 53 kB 20.4 kB 18.7 kB
createApp 61.5 kB 23.7 kB 21.6 kB
createSSRApp 66.4 kB 25.7 kB 23.4 kB
defineCustomElement 67.8 kB 25.6 kB 23.3 kB
overall 77.7 kB 29.5 kB 26.8 kB

@edison1105
edison1105 merged commit ce70d74 into main Dec 3, 2026
16 checks passed
@edison1105
edison1105 deleted the edison/fix/vshow-hydration-display branch December 3, 2026 07:24
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. scope:hydration

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant