Skip to content

Commit 7a842ab

Browse files
committed
wip: refactor
1 parent e6e0160 commit 7a842ab

File tree

8 files changed

+569
-605
lines changed

8 files changed

+569
-605
lines changed

packages/compiler-ssr/src/ssrCodegenTransform.ts

+9-4
Original file line numberDiff line numberDiff line change
@@ -302,8 +302,8 @@ function processChildrenDynamicInfo(
302302
const child = filteredChildren[i]
303303
if (
304304
isStaticChildNode(child) ||
305-
// v-if has an anchor, which can be used to distinguish the boundary
306-
child.type === NodeTypes.IF
305+
// fragment has it's own anchor, which can be used to distinguish the boundary
306+
isFragmentChild(child)
307307
) {
308308
continue
309309
}
@@ -359,10 +359,10 @@ function processChildrenDynamicInfo(
359359
}
360360

361361
/**
362-
* Check if a node should be processed as dynamic.
362+
* Check if a node should be processed as dynamic child.
363363
* This is primarily used in Vapor mode hydration to wrap dynamic parts
364364
* with markers (`<!--[[-->` and `<!--]]-->`).
365-
* The purpose is to distinguish the boundaries of nodes during hydration
365+
* The purpose is to distinguish the boundaries of nodes during vapor hydration
366366
*
367367
* 1. two consecutive dynamic nodes should only wrap the second one
368368
* <element>
@@ -416,3 +416,8 @@ function shouldProcessChildAsDynamic(
416416

417417
return false
418418
}
419+
420+
function isFragmentChild(child: TemplateChildNode): boolean {
421+
const { type } = child
422+
return type === NodeTypes.IF || type === NodeTypes.FOR
423+
}

packages/runtime-core/src/hydration.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ import {
2626
includeBooleanAttr,
2727
isBooleanAttr,
2828
isDynamicAnchor,
29-
isDynamicFragmentEndAnchor,
3029
isKnownHtmlAttr,
3130
isKnownSvgAttr,
3231
isOn,
3332
isRenderableAttrValue,
3433
isReservedProp,
3534
isString,
35+
isVaporFragmentEndAnchor,
3636
normalizeClass,
3737
normalizeStyle,
3838
stringifyStyle,
@@ -126,7 +126,7 @@ export function createHydrationFunctions(
126126
// skip if:
127127
// - dynamic anchors (`<!--[[-->`, `<!--][-->`)
128128
// - dynamic fragment end anchors (e.g. `<!--if-->`, `<!--for-->`)
129-
if (n && (isDynamicAnchor(n) || isDynamicFragmentEndAnchor(n))) {
129+
if (n && (isDynamicAnchor(n) || isVaporFragmentEndAnchor(n))) {
130130
n = next(n)
131131
}
132132
return n
@@ -158,7 +158,7 @@ export function createHydrationFunctions(
158158
slotScopeIds: string[] | null,
159159
optimized = false,
160160
): Node | null => {
161-
if (isDynamicAnchor(node) || isDynamicFragmentEndAnchor(node)) {
161+
if (isDynamicAnchor(node) || isVaporFragmentEndAnchor(node)) {
162162
node = nextSibling(node)!
163163
}
164164
optimized = optimized || !!vnode.dynamicChildren

0 commit comments

Comments
 (0)