-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
fix(compile-core): track KeepAlive as block inside v-for #12915
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
base: main
Are you sure you want to change the base?
Conversation
Size ReportBundles
Usages
|
@vue/compiler-core
@vue/compiler-dom
@vue/compiler-ssr
@vue/compiler-sfc
@vue/runtime-core
@vue/reactivity
@vue/runtime-dom
@vue/server-renderer
@vue/shared
vue
@vue/compat
commit: |
ad243e7
to
9b6ecde
Compare
I'm struggling to understand the proposed change. Here's what I've got so far... When
But when
So the proposed fix is to use But that raises several questions:
I wanted to start by investigating point 2 in particular, so I tried unmounting the components inside the Like the original reproduction, it works fine with |
WalkthroughThe changes update the Changes
Sequence Diagram(s)sequenceDiagram
participant App
participant KeepAlive
participant CompA
participant CompB
App->>KeepAlive: Render with CompA (via v-for, stable fragment)
KeepAlive->>CompA: Mount CompA
App->>KeepAlive: Toggle to CompB
KeepAlive-->>CompA: Unmount CompA
KeepAlive->>CompB: Mount CompB
Assessment against linked issues
Suggested labels
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
🧰 Additional context used🧬 Code Graph Analysis (1)packages/compiler-core/src/transforms/vFor.ts (1)
🔇 Additional comments (4)
✨ 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 (
|
/ecosystem-ci run |
📝 Ran ecosystem CI: Open
|
@skirtles-code Root Cause of the Bug:The // CompA is KeepAlive child
n1.dynamicChildren = [CompA, KeepAlive] Issue Analysis:
Solution:When function render(_ctx, _cache, $props, $setup, $data, $options) {
return (_openBlock(), _createElementBlock(_Fragment, null, _renderList($setup.maxLength, (idx) => {
- return _createVNode(_KeepAlive, { include: ['foo'] }, [
+ return (_openBlock(), _createBlock(_KeepAlive, { include: ['foo'] }, [
(_openBlock(), _createBlock(_resolveDynamicComponent($setup.val ? $setup.CompB : $setup.CompA)))
], 1024 /* DYNAMIC_SLOTS */)
}), 64 /* STABLE_FRAGMENT */))
} The scenario where Another potential solution would be: So far, no similar issues have been observed with other built-in components when used alongside |
close #12914
Summary by CodeRabbit
Bug Fixes
KeepAlive
withinv-for
loops, ensuring correct tracking and lifecycle management even in stable fragments.Tests
KeepAlive
children are properly unmounted and remounted when used inside a stable fragment and switched dynamically within a keyed list.