fix(runtime-core): ensure correct anchor el for unresolved async components#13560
Conversation
|
""" WalkthroughThe patch introduces tracking of placeholder DOM elements for unresolved async components inside Suspense by adding a Changes
Sequence Diagram(s)sequenceDiagram
participant Renderer
participant SuspenseBoundary
participant AsyncComponent
participant PlaceholderNode
participant DOM
Renderer->>SuspenseBoundary: Mount component with async dependency
SuspenseBoundary->>PlaceholderNode: Create and insert placeholder comment node
SuspenseBoundary->>Renderer: Assign placeholder to vnode
AsyncComponent-->>SuspenseBoundary: Async component resolves
SuspenseBoundary->>DOM: Replace placeholder with resolved component DOM
Assessment against linked issues
Assessment against linked issues: Out-of-scope changesNo out-of-scope changes detected. Suggested labels
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 (5)
✨ 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
|
@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.
Actionable comments posted: 0
🧹 Nitpick comments (1)
packages/runtime-core/src/renderer.ts (1)
1982-1990: Good fix for async component anchor determination, but consider additional safety checks.The logic correctly handles the case where an async component hasn't resolved yet by using
component.subTree.elinstead ofvnode.el. This is important because for unresolved async components, the vnode'selproperty may not yet point to the correct DOM element.However, consider adding a null safety check for the
subTreeproperty:let anchor = parentAnchor if (nextIndex + 1 < l2) { const anchorVnode = c2[nextIndex + 1] as VNode - if (anchorVnode.component && !anchorVnode.component.asyncResolved) { + if (anchorVnode.component && !anchorVnode.component.asyncResolved && anchorVnode.component.subTree) { anchor = anchorVnode.component.subTree.el } else { anchor = anchorVnode.el } }This ensures that
subTreeexists before accessing itselproperty, which could be important during the component's lifecycle.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/runtime-core/src/renderer.ts(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
packages/runtime-core/src/renderer.ts (1)
packages/runtime-core/src/vnode.ts (1)
VNode(160-256)
⏰ 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 / e2e-test
…fork into fix-patch-keyed-children-w/-async-component
|
/ecosystem-ci run |
|
📝 Ran ecosystem CI: Open
|
close #13559
When the asynchronous component is not resolved, Vue will use a placeholder to occupy the position of the rendering result. At this time, we need to get the actual placeholder el to ensure that the anchor point of the subsequent insertion operation is correct.
playground with this pr
Summary by CodeRabbit
Bug Fixes
Tests