fix(teleport): properly handling disabled teleport target anchor#14417
fix(teleport): properly handling disabled teleport target anchor#14417edison1105 merged 2 commits intomainfrom
Conversation
📝 WalkthroughWalkthroughIntroduces a lookahead hydration helper Changes
Sequence Diagram(s)mermaid Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
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.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/runtime-core/src/components/Teleport.ts (1)
533-549:⚠️ Potential issue | 🔴 CriticalFix anchor parameter type to accept non-Element nodes.
prepareAnchorreceives aninsertfunction that acceptsRendererNode(including non-Element nodes like Comment nodes used in hydration) as the anchor parameter, but declares the anchor parameter asRendererElement, which is too narrow.Proposed fix
function prepareAnchor( target: RendererElement | null, vnode: TeleportVNode, createText: RendererOptions['createText'], insert: RendererOptions['insert'], - anchor: RendererElement | null = null, + anchor: RendererNode | null = null, ) {
b7acd89 to
04eb5e7
Compare
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/runtime-core/src/components/Teleport.ts (1)
459-481:⚠️ Potential issue | 🟡 MinorAdvance
_lpawhen anchors are synthesized.When SSR anchors are missing,
prepareAnchorcreates new anchors but_lparemains unset. With multiple teleports targeting the same element, the next hydration pass can restart attarget.firstChild, leading to mismatched hydration/duplicate anchors. Consider advancing_lpaimmediately afterprepareAnchorin both branches.Suggested fix (update _lpa after creating anchors)
- if (!vnode.targetAnchor) { - prepareAnchor( - target, - vnode, - createText, - insert, - // if target is the same as the main view, insert anchors before current node - // to avoid hydrating mismatch - parentNode(node)! === target ? node : null, - ) - } + if (!vnode.targetAnchor) { + const createdAnchor = prepareAnchor( + target, + vnode, + createText, + insert, + // if target is the same as the main view, insert anchors before current node + // to avoid hydrating mismatch + parentNode(node)! === target ? node : null, + ) + ;(target as TeleportTargetElement)._lpa = nextSibling( + createdAnchor as Node, + ) + } ... - if (!vnode.targetAnchor) { - prepareAnchor(target, vnode, createText, insert) - } + if (!vnode.targetAnchor) { + const createdAnchor = prepareAnchor(target, vnode, createText, insert) + ;(target as TeleportTargetElement)._lpa = nextSibling( + createdAnchor as Node, + ) + }
e09f96e to
d62d5c9
Compare
|
/ecosystem-ci run |
|
📝 Ran ecosystem CI: Open
|
close #14412
Summary by CodeRabbit
Bug Fixes
Refactor
Tests