fix(v-model): preserve remaining text input types before hydration - #15211
fix(v-model): preserve remaining text input types before hydration#15211lazerg wants to merge 1 commit into
Conversation
📝 WalkthroughWalkthroughThe change extends ChangesHydration value preservation
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Suggested labels: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ 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 |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/runtime-core/__tests__/hydration.spec.ts (1)
1713-1732: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd coverage for
email[multiple]normalization.Line 82 has a separate comma-token normalization path. This parameterized test covers
multiple.Add a hydration test with whitespace around comma-separated addresses. Verify that hydration preserves the browser value and does not replace the original bound value with the sanitized value.
🤖 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 1713 - 1732, Extend the hydration coverage near the existing text-input test to include an email input with the multiple attribute and comma-separated addresses containing surrounding whitespace. During SSR hydration, set the browser value to the whitespace-preserving address string and verify both input.value and the bound reactive state retain that original value rather than the normalized form.
🤖 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.
Nitpick comments:
In `@packages/runtime-core/__tests__/hydration.spec.ts`:
- Around line 1713-1732: Extend the hydration coverage near the existing
text-input test to include an email input with the multiple attribute and
comma-separated addresses containing surrounding whitespace. During SSR
hydration, set the browser value to the whitespace-preserving address string and
verify both input.value and the bound reactive state retain that original value
rather than the normalized form.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 6482b874-d453-46b1-9574-99836601e76e
📒 Files selected for processing (2)
packages/runtime-core/__tests__/hydration.spec.tspackages/runtime-dom/src/directives/vModel.ts
ff1103e to
d140e73
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
close #15210
Follow-up to #14411, which only preserved values for
textinputs and textareas. The same handling now coverssearch,tel,password,emailandurl, whose value sanitization is a plain text normalization that can be reproduced fromdefaultValue.The other types are left out on purpose.
number,date,month,week,time,datetime-local,colorandrangesanitize based on validity or apply their own normalization, so a server rendered value can come back from the DOM as an empty string, a normalized date, a lowercased/defaulted color, or (forrange) a clamped value, without anyone typing. Comparing those againstdefaultValuewould report an edit that never happened and push the browser's replacement value into the model.hidden,submit,buttonand friends can't be edited by the user, so there is nothing to preserve there.Summary by CodeRabbit
v-model, preserving values entered or bound before hydration.