Skip to content

Commit 9e16723

Browse files
committed
fix: use empty comment as if fragment anchor
1 parent 27b4319 commit 9e16723

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

packages/runtime-vapor/src/fragment.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import type { TransitionHooks } from '@vue/runtime-dom'
1313
import {
1414
advanceHydrationNode,
1515
currentHydrationNode,
16-
isComment,
1716
isHydrating,
1817
locateHydrationNode,
1918
locateVaporFragmentAnchor,
@@ -75,7 +74,7 @@ export class DynamicFragment extends VaporFragment {
7574

7675
update(render?: BlockFn, key: any = render): void {
7776
if (key === this.current) {
78-
if (isHydrating) this.hydrate(this.anchorLabel!)
77+
if (isHydrating) this.hydrate(this.anchorLabel!, true)
7978
return
8079
}
8180
this.current = key
@@ -145,11 +144,11 @@ export class DynamicFragment extends VaporFragment {
145144
}
146145
}
147146

148-
hydrate(label: string): void {
147+
hydrate(label: string, isEmpty: boolean = false): void {
149148
// for `v-if="false"` the node will be an empty comment, use it as the anchor.
150149
// otherwise, find next sibling vapor fragment anchor
151-
if (label === 'if' && isComment(currentHydrationNode!, '')) {
152-
this.anchor = currentHydrationNode
150+
if (label === 'if' && isEmpty) {
151+
this.anchor = locateVaporFragmentAnchor(currentHydrationNode!, '')!
153152
} else {
154153
let anchor = locateVaporFragmentAnchor(currentHydrationNode!, label)!
155154
if (!anchor && (label === 'slot' || label === 'if')) {

0 commit comments

Comments
 (0)