Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9579911

Browse files
committed
fix(hydration): scope slot boundary restoration to slot-owned close markers
1 parent 10325c0 commit 9579911

1 file changed

Lines changed: 12 additions & 9 deletions

File tree

‎packages/runtime-vapor/src/fragment.ts‎

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -527,15 +527,6 @@ export class DynamicFragment extends VaporFragment {
527527
}
528528
}
529529

530-
export let currentSlotEndAnchor: Node | null = null
531-
function setCurrentSlotEndAnchor(end: Node | null): Node | null {
532-
try {
533-
return currentSlotEndAnchor
534-
} finally {
535-
currentSlotEndAnchor = end
536-
}
537-
}
538-
539530
function isReusableDynamicFragmentAnchor(
540531
node: Comment,
541532
anchorLabel: string,
@@ -549,6 +540,15 @@ function isReusableDynamicFragmentAnchor(
549540
)
550541
}
551542

543+
export let currentSlotEndAnchor: Node | null = null
544+
function setCurrentSlotEndAnchor(end: Node | null): Node | null {
545+
try {
546+
return currentSlotEndAnchor
547+
} finally {
548+
currentSlotEndAnchor = end
549+
}
550+
}
551+
552552
// Tracks slot fallback hydration that falls through an inner empty fragment,
553553
// e.g.
554554
// - `<slot><template v-if="false" /></slot>`
@@ -578,13 +578,15 @@ export class SlotFragment extends DynamicFragment {
578578
): void {
579579
let prevEndAnchor: Node | null = null
580580
let pushedEndAnchor = false
581+
let exitHydrationBoundary: (() => void) | undefined
581582
if (isHydrating) {
582583
locateHydrationNode()
583584
if (isComment(currentHydrationNode!, '[')) {
584585
const endAnchor = locateEndAnchor(currentHydrationNode)
585586
setCurrentHydrationNode(currentHydrationNode.nextSibling)
586587
prevEndAnchor = setCurrentSlotEndAnchor(endAnchor)
587588
pushedEndAnchor = true
589+
exitHydrationBoundary = enterHydrationBoundary(endAnchor)
588590
}
589591
}
590592

@@ -627,6 +629,7 @@ export class SlotFragment extends DynamicFragment {
627629
if (isHydrating && pushedEndAnchor) {
628630
setCurrentSlotEndAnchor(prevEndAnchor)
629631
}
632+
exitHydrationBoundary && exitHydrationBoundary()
630633
}
631634
}
632635
}

0 commit comments

Comments
 (0)