fix(compiler-core): prefix key with v-memo outside v-for#14927
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThis PR fixes a compiler bug where Changesv-memo key expression prefixing fix
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
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 |
Size ReportBundles
Usages
|
@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: |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ad9c0cdd54
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| // key has been processed in transformFor(vMemo + vFor) | ||
| !( | ||
| memo && | ||
| vFor && |
There was a problem hiding this comment.
Avoid reprocessing v-for memo keys
When a v-memo element is also under v-for and its :key uses an outer-scope value such as :key="foo", transformFor has already processed the key to _ctx.foo. The structural v-for directive is spliced out before this element is traversed as the ForNode child, so this new vFor check is false here and the key is processed a second time, turning _ctx.foo into _ctx._ctx.foo in the generated render/cache comparison code. The skip still needs to cover keys already handled by transformFor while allowing only non-v-for v-memo keys through.
Useful? React with 👍 / 👎.
|
duplicate of #14922 |
Fixes #14920.\n\nThis narrows the special-case skip for v-memo + :key expression processing to the scenario where v-for is also present. transformFor already processes that key expression eagerly, but plain elements with v-memo still need the normal transformExpression pass so identifiers are prefixed correctly.\n\nTest: pnpm vitest packages/compiler-core/tests/transforms/vMemo.spec.ts --run
Summary by CodeRabbit
Bug Fixes
v-memodirective when combined withv-forto correctly handle key binding processing, preventing unintended optimizations in these scenarios.Tests
v-memodirective with:keybinding to ensure templates with this combination compile with the expected output structure.