fix(hydration): force patch dynamic props when hydrating#9083
Conversation
Size ReportBundles
Usages
|
…Hydrate # Conflicts: # packages/runtime-core/__tests__/hydration.spec.ts # packages/runtime-core/src/hydration.ts
…Hydrate # Conflicts: # packages/runtime-core/__tests__/hydration.spec.ts # packages/runtime-core/src/hydration.ts
|
up |
…psHydrate # Conflicts: # packages/runtime-core/__tests__/hydration.spec.ts
…psHydrate # Conflicts: # packages/runtime-core/__tests__/hydration.spec.ts # packages/runtime-core/src/hydration.ts
@vue/compiler-core
@vue/compiler-dom
@vue/compiler-sfc
@vue/compiler-ssr
@vue/reactivity
@vue/runtime-core
@vue/runtime-dom
@vue/server-renderer
@vue/shared
vue
@vue/compat
commit: |
# Conflicts: # packages/runtime-core/src/hydration.ts
📝 WalkthroughWalkthroughHydration now considers vnode dynamic props when deciding whether to patch server-rendered elements, and it only applies prop updates for keys marked dynamic. Tests cover production ChangesHydration dynamic-prop patching
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
|
/ecosystem-ci run |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
packages/runtime-core/__tests__/hydration.spec.ts (1)
2676-2722: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd a direct
img srchydration regression test for the reported case.Given the linked objective explicitly calls out
img src, adding one focused assertion for dynamicsrcpatching would lock coverage to the original bug report.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/runtime-core/__tests__/hydration.spec.ts` around lines 2676 - 2722, Add a focused hydration regression test for the reported img src case alongside the existing force-patch dynamic props coverage. In the hydration spec, extend the test area around mountWithHydration/createVNode to cover an img element with a declared dynamic src prop, then assert the hydrated DOM updates src from server to client while leaving unrelated props untouched. Use the existing hydration helpers and PatchFlags.PROPS pattern so the new test directly exercises the same path as the current dynamic-props tests.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/runtime-core/__tests__/hydration.spec.ts`:
- Around line 2679-2699: The hydration test mutates the global __DEV__ flag and
currently restores it to a hardcoded true, which can leak state if the prior
value was different. In the hydration.spec.ts test around mountWithHydration,
capture the original __DEV__ value before setting it to false, then restore that
saved value in the finally block instead of assuming true. Keep the change
localized to this test so the global state is properly isolated.
---
Nitpick comments:
In `@packages/runtime-core/__tests__/hydration.spec.ts`:
- Around line 2676-2722: Add a focused hydration regression test for the
reported img src case alongside the existing force-patch dynamic props coverage.
In the hydration spec, extend the test area around
mountWithHydration/createVNode to cover an img element with a declared dynamic
src prop, then assert the hydrated DOM updates src from server to client while
leaving unrelated props untouched. Use the existing hydration helpers and
PatchFlags.PROPS pattern so the new test directly exercises the same path as the
current dynamic-props tests.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: f3687596-9029-488d-8ec5-941ed8007ff4
📒 Files selected for processing (2)
packages/runtime-core/__tests__/hydration.spec.tspackages/runtime-core/src/hydration.ts
|
📝 Ran ecosystem CI: Open
|
close: #9033
The same code is executed on the client and the server, but some dynamic props may be inconsistent between the two runs (such as timestamps), I think they should always be consistent with the client
Summary by CodeRabbit
Bug Fixes
Tests