You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(runtime-dom): restore v-show display after hydration - #16548
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.
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.
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: 4
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
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
[#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
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.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
🔨 p3-minor-bugPriority 3: this fixes a bug, but is an edge case that only affects very specific usage.scope:hydration
1 participant
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
close #16544
Summary by CodeRabbit
v-showcorrectly restore their intended display style when shown, including styles provided as strings, objects, or arrays and values marked!important.