Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 9k
fix(ssr): handle initial selected state for select with v-model + v-for/v-if option#13487
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Conversation
edison1105 commented Jun 17, 2025 • edited by coderabbitai bot
Loading Uh oh!
There was an error while loading. Please reload this page.
edited by coderabbitai bot
Uh oh!
There was an error while loading. Please reload this page.
coderabbitaibot commented Jun 17, 2025 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
WalkthroughThe update enhances SSR code generation for Changes
Sequence Diagram(s)sequenceDiagram participant Template as Template AST participant SSRTransform as SSR VModel Transform participant SSRCode as SSR Codegen Template->>SSRTransform: Encounter <select multiple v-model> SSRTransform->>SSRTransform: Find <optgroup> with children loop For each child in <optgroup> alt Element node SSRTransform->>SSRTransform: processOption(child) else FOR node SSRTransform->>SSRTransform: For each FOR child, processOption(child) else IF node SSRTransform->>SSRTransform: For each IF branch, processOption(branch child) end end SSRTransform->>SSRCode: Generate SSR code with correct selected attribute logic Assessment against linked issues
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
⏰ Context from checks skipped due to timeout of 90000ms (8)
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File ( |
Size ReportBundles
Usages
|
pkg-pr-newbot commented Jun 17, 2025 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
@vue/compiler-core@vue/compiler-dom@vue/compiler-sfc@vue/compiler-ssr@vue/reactivity@vue/runtime-core@vue/runtime-dom@vue/server-renderer@vue/sharedvue@vue/compatcommit: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
packages/compiler-ssr/src/transforms/ssrVModel.ts (1)
68-78: Duplicate traversal logic – consider extracting a shared helperThe new block repeats almost exactly the traversal logic that already exists in
processChildren(lines 174-185). Duplicating this walker increases maintenance cost and the risk of future divergence.A small refactor can DRY the code and keep the recursion rules in one place:
- } else if (plainNode.tag === 'optgroup'){- plainNode.children.forEach(option =>{- if (option.type === NodeTypes.ELEMENT){- processOption(option as PlainElementNode)- } else if (option.type === NodeTypes.FOR){- option.children.forEach(c => processOption(c as PlainElementNode))- } else if (option.type === NodeTypes.IF){- option.branches.forEach(b =>- b.children.forEach(c => processOption(c as PlainElementNode)),- )- }- })+ } else if (plainNode.tag === 'optgroup'){+ // re-use the generic walker so the traversal rules stay in one place+ processChildren(plainNode.children) }That change would require hoisting
processChildrenoutside the<select>branch (or defining a module-level helper) but would eliminate the duplicate code and keep the traversal strategy consistent.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
packages/compiler-ssr/__tests__/ssrVModel.spec.ts(1 hunks)packages/compiler-ssr/src/transforms/ssrVModel.ts(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (4)
- GitHub Check: Redirect rules
- GitHub Check: Header rules
- GitHub Check: Pages changed
- GitHub Check: test / unit-test-windows
🔇 Additional comments (1)
packages/compiler-ssr/__tests__/ssrVModel.spec.ts (1)
170-225: 👍 Great addition of edge-case coverageThe two new cases (
v-forandv-ifinside<optgroup>) hit the exact scenarios the bug fix targets and safeguard against regressions. Snapshot assertions also verify thatselectedhandling and text interpolation remain correct.
skirtles-code left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we also handle nesting? e.g. v-if inside v-for?
Maybe processChildren could be moved to a scope where it can be called from processOption? I think that would handle the recursion and remove the duplication of the v-for/v-if logic.
edison1105 commented Jun 18, 2025
@skirtles-code Updated~ |
1552095 into mainUh oh!
There was an error while loading. Please reload this page.
close#13486
Summary by CodeRabbit
Tests
<select multiple>elements with<optgroup>containing dynamic<option>elements usingv-forandv-ifdirectives.Bug Fixes
<optgroup>, ensuring correct handling of loops and conditionals during server-side rendering.