Skip to content

Commit 700f49e

Browse files
committed
wip: hydration for slots
1 parent 2f00264 commit 700f49e

File tree

15 files changed

+441
-99
lines changed

15 files changed

+441
-99
lines changed

packages/compiler-ssr/__tests__/ssrComponent.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ describe('ssr: components', () => {
246246
_ssrRenderList(list, (i) => {
247247
_push(\`<span\${_scopeId}></span>\`)
248248
})
249-
_push(\`<!--]--></div>\`)
249+
_push(\`<!--]--><!--for--></div>\`)
250250
_push(\`<!--if-->\`)
251251
} else {
252252
_push(\`<!---->\`)
@@ -270,7 +270,7 @@ describe('ssr: components', () => {
270270
_ssrRenderList(_ctx.list, (i) => {
271271
_push(\`<span\${_scopeId}></span>\`)
272272
})
273-
_push(\`<!--]--></div>\`)
273+
_push(\`<!--]--><!--for--></div>\`)
274274
_push(\`<!--if-->\`)
275275
} else {
276276
_push(\`<!---->\`)

packages/compiler-ssr/__tests__/ssrVFor.spec.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ describe('ssr: v-for', () => {
1010
_ssrRenderList(_ctx.list, (i) => {
1111
_push(\`<div></div>\`)
1212
})
13-
_push(\`<!--]-->\`)
13+
_push(\`<!--]--><!--for-->\`)
1414
}"
1515
`)
1616
})
@@ -25,7 +25,7 @@ describe('ssr: v-for', () => {
2525
_ssrRenderList(_ctx.list, (i) => {
2626
_push(\`<div>foo<span>bar</span></div>\`)
2727
})
28-
_push(\`<!--]-->\`)
28+
_push(\`<!--]--><!--for-->\`)
2929
}"
3030
`)
3131
})
@@ -51,9 +51,9 @@ describe('ssr: v-for', () => {
5151
_ssrInterpolate(j)
5252
}</div>\`)
5353
})
54-
_push(\`<!--]--></div>\`)
54+
_push(\`<!--]--><!--for--></div>\`)
5555
})
56-
_push(\`<!--]-->\`)
56+
_push(\`<!--]--><!--for-->\`)
5757
}"
5858
`)
5959
})
@@ -68,7 +68,7 @@ describe('ssr: v-for', () => {
6868
_ssrRenderList(_ctx.list, (i) => {
6969
_push(\`<!--[-->\${_ssrInterpolate(i)}<!--]-->\`)
7070
})
71-
_push(\`<!--]-->\`)
71+
_push(\`<!--]--><!--for-->\`)
7272
}"
7373
`)
7474
})
@@ -85,7 +85,7 @@ describe('ssr: v-for', () => {
8585
_ssrRenderList(_ctx.list, (i) => {
8686
_push(\`<span>\${_ssrInterpolate(i)}</span>\`)
8787
})
88-
_push(\`<!--]-->\`)
88+
_push(\`<!--]--><!--for-->\`)
8989
}"
9090
`)
9191
})
@@ -107,7 +107,7 @@ describe('ssr: v-for', () => {
107107
_ssrInterpolate(i + 1)
108108
}</span><!--]-->\`)
109109
})
110-
_push(\`<!--]-->\`)
110+
_push(\`<!--]--><!--for-->\`)
111111
}"
112112
`)
113113
})
@@ -127,7 +127,7 @@ describe('ssr: v-for', () => {
127127
_ssrRenderList(_ctx.list, ({ foo }, index) => {
128128
_push(\`<div>\${_ssrInterpolate(foo + _ctx.bar + index)}</div>\`)
129129
})
130-
_push(\`<!--]-->\`)
130+
_push(\`<!--]--><!--for-->\`)
131131
}"
132132
`)
133133
})

packages/compiler-ssr/__tests__/ssrVIf.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ describe('ssr: v-if', () => {
147147
_ssrRenderList(_ctx.list, (i) => {
148148
_push(\`<div></div>\`)
149149
})
150-
_push(\`<!--]-->\`)
150+
_push(\`<!--]--><!--for-->\`)
151151
_push(\`<!--if-->\`)
152152
} else {
153153
_push(\`<!---->\`)

packages/compiler-ssr/__tests__/ssrVModel.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ describe('ssr: v-model', () => {
7070
: _ssrLooseEqual(_ctx.model, i))) ? " selected" : ""
7171
}></option>\`)
7272
})
73-
_push(\`<!--]--></select></div>\`)
73+
_push(\`<!--]--><!--for--></select></div>\`)
7474
}"
7575
`)
7676

packages/compiler-ssr/src/ssrCodegenTransform.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,7 @@ function processChildrenDynamicInfo(
381381
* <Comp/> // Dynamic node -> should be wrapped
382382
* <Comp/> // Dynamic node -> should NOT be wrapped
383383
* <element/> // Static node
384+
* </element>
384385
*/
385386
function shouldProcessChildAsDynamic(
386387
parent: { tag?: string; children: TemplateChildNode[] },

packages/compiler-ssr/src/transforms/ssrVFor.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@ export function ssrProcessFor(
4949
)
5050
if (!disableNestedFragments) {
5151
context.pushStringPart(`<!--]-->`)
52-
} else {
53-
// add anchor for non-fragment v-for
54-
context.pushStringPart(`<!--${FOR_ANCHOR_LABEL}-->`)
5552
}
53+
// v-for anchor for vapor hydration
54+
context.pushStringPart(`<!--${FOR_ANCHOR_LABEL}-->`)
5655
}

packages/runtime-core/src/hydration.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ export function createHydrationFunctions(
125125
let n = next(node)
126126
// skip if:
127127
// - dynamic anchors (`<!--[[-->`, `<!--][-->`)
128-
// - dynamic fragment end anchors (e.g. `<!--if-->`, `<!--for-->`)
128+
// - vapor fragment end anchors (e.g. `<!--if-->`, `<!--for-->`)
129129
if (n && (isDynamicAnchor(n) || isVaporFragmentEndAnchor(n))) {
130130
n = next(n)
131131
}

0 commit comments

Comments
 (0)