feat(ssr/suspense): suspense hydration
In order to support hydration of async components, server-rendered fragments must be explicitly marked with comment nodes.
This commit is contained in:
@@ -219,11 +219,11 @@ describe('ssr: components', () => {
|
||||
foo: ({ list }, _push, _parent, _scopeId) => {
|
||||
if (_push) {
|
||||
if (_ctx.ok) {
|
||||
_push(\`<div\${_scopeId}>\`)
|
||||
_push(\`<div\${_scopeId}><!--1-->\`)
|
||||
_ssrRenderList(list, (i) => {
|
||||
_push(\`<span\${_scopeId}></span>\`)
|
||||
})
|
||||
_push(\`</div>\`)
|
||||
_push(\`<!--0--></div>\`)
|
||||
} else {
|
||||
_push(\`<!---->\`)
|
||||
}
|
||||
@@ -242,11 +242,11 @@ describe('ssr: components', () => {
|
||||
bar: ({ ok }, _push, _parent, _scopeId) => {
|
||||
if (_push) {
|
||||
if (ok) {
|
||||
_push(\`<div\${_scopeId}>\`)
|
||||
_push(\`<div\${_scopeId}><!--1-->\`)
|
||||
_ssrRenderList(_ctx.list, (i) => {
|
||||
_push(\`<span\${_scopeId}></span>\`)
|
||||
})
|
||||
_push(\`</div>\`)
|
||||
_push(\`<!--0--></div>\`)
|
||||
} else {
|
||||
_push(\`<!---->\`)
|
||||
}
|
||||
@@ -281,7 +281,7 @@ describe('ssr: components', () => {
|
||||
.toMatchInlineSnapshot(`
|
||||
"
|
||||
return function ssrRender(_ctx, _push, _parent) {
|
||||
_push(\`<div></div>\`)
|
||||
_push(\`<!--1--><div></div><!--0-->\`)
|
||||
}"
|
||||
`)
|
||||
|
||||
|
||||
@@ -6,9 +6,11 @@ describe('ssr: v-for', () => {
|
||||
"const { ssrRenderList: _ssrRenderList } = require(\\"@vue/server-renderer\\")
|
||||
|
||||
return function ssrRender(_ctx, _push, _parent) {
|
||||
_push(\`<!--1-->\`)
|
||||
_ssrRenderList(_ctx.list, (i) => {
|
||||
_push(\`<div></div>\`)
|
||||
})
|
||||
_push(\`<!--0-->\`)
|
||||
}"
|
||||
`)
|
||||
})
|
||||
@@ -19,9 +21,11 @@ describe('ssr: v-for', () => {
|
||||
"const { ssrRenderList: _ssrRenderList } = require(\\"@vue/server-renderer\\")
|
||||
|
||||
return function ssrRender(_ctx, _push, _parent) {
|
||||
_push(\`<!--1-->\`)
|
||||
_ssrRenderList(_ctx.list, (i) => {
|
||||
_push(\`<div>foo<span>bar</span></div>\`)
|
||||
})
|
||||
_push(\`<!--0-->\`)
|
||||
}"
|
||||
`)
|
||||
})
|
||||
@@ -37,8 +41,9 @@ describe('ssr: v-for', () => {
|
||||
"const { ssrInterpolate: _ssrInterpolate, ssrRenderList: _ssrRenderList } = require(\\"@vue/server-renderer\\")
|
||||
|
||||
return function ssrRender(_ctx, _push, _parent) {
|
||||
_push(\`<!--1-->\`)
|
||||
_ssrRenderList(_ctx.list, (row, i) => {
|
||||
_push(\`<div>\`)
|
||||
_push(\`<div><!--1-->\`)
|
||||
_ssrRenderList(row, (j) => {
|
||||
_push(\`<div>\${
|
||||
_ssrInterpolate(i)
|
||||
@@ -46,8 +51,9 @@ describe('ssr: v-for', () => {
|
||||
_ssrInterpolate(j)
|
||||
}</div>\`)
|
||||
})
|
||||
_push(\`</div>\`)
|
||||
_push(\`<!--0--></div>\`)
|
||||
})
|
||||
_push(\`<!--0-->\`)
|
||||
}"
|
||||
`)
|
||||
})
|
||||
@@ -58,9 +64,11 @@ describe('ssr: v-for', () => {
|
||||
"const { ssrInterpolate: _ssrInterpolate, ssrRenderList: _ssrRenderList } = require(\\"@vue/server-renderer\\")
|
||||
|
||||
return function ssrRender(_ctx, _push, _parent) {
|
||||
_push(\`<!--1-->\`)
|
||||
_ssrRenderList(_ctx.list, (i) => {
|
||||
_push(\`\${_ssrInterpolate(i)}\`)
|
||||
_push(\`<!--1-->\${_ssrInterpolate(i)}<!--0-->\`)
|
||||
})
|
||||
_push(\`<!--0-->\`)
|
||||
}"
|
||||
`)
|
||||
})
|
||||
@@ -73,9 +81,11 @@ describe('ssr: v-for', () => {
|
||||
"const { ssrInterpolate: _ssrInterpolate, ssrRenderList: _ssrRenderList } = require(\\"@vue/server-renderer\\")
|
||||
|
||||
return function ssrRender(_ctx, _push, _parent) {
|
||||
_push(\`<!--1-->\`)
|
||||
_ssrRenderList(_ctx.list, (i) => {
|
||||
_push(\`<span>\${_ssrInterpolate(i)}</span>\`)
|
||||
})
|
||||
_push(\`<!--0-->\`)
|
||||
}"
|
||||
`)
|
||||
})
|
||||
@@ -89,13 +99,15 @@ describe('ssr: v-for', () => {
|
||||
"const { ssrInterpolate: _ssrInterpolate, ssrRenderList: _ssrRenderList } = require(\\"@vue/server-renderer\\")
|
||||
|
||||
return function ssrRender(_ctx, _push, _parent) {
|
||||
_push(\`<!--1-->\`)
|
||||
_ssrRenderList(_ctx.list, (i) => {
|
||||
_push(\`<span>\${
|
||||
_push(\`<!--1--><span>\${
|
||||
_ssrInterpolate(i)
|
||||
}</span><span>\${
|
||||
_ssrInterpolate(i + 1)
|
||||
}</span>\`)
|
||||
}</span><!--0-->\`)
|
||||
})
|
||||
_push(\`<!--0-->\`)
|
||||
}"
|
||||
`)
|
||||
})
|
||||
@@ -111,9 +123,11 @@ describe('ssr: v-for', () => {
|
||||
"const { ssrInterpolate: _ssrInterpolate, ssrRenderList: _ssrRenderList } = require(\\"@vue/server-renderer\\")
|
||||
|
||||
return function ssrRender(_ctx, _push, _parent) {
|
||||
_push(\`<!--1-->\`)
|
||||
_ssrRenderList(_ctx.list, ({ foo }, index) => {
|
||||
_push(\`<div>\${_ssrInterpolate(foo + _ctx.bar + index)}</div>\`)
|
||||
})
|
||||
_push(\`<!--0-->\`)
|
||||
}"
|
||||
`)
|
||||
})
|
||||
|
||||
@@ -80,7 +80,7 @@ describe('ssr: v-if', () => {
|
||||
"
|
||||
return function ssrRender(_ctx, _push, _parent) {
|
||||
if (_ctx.foo) {
|
||||
_push(\`hello\`)
|
||||
_push(\`<!--1-->hello<!--0-->\`)
|
||||
} else {
|
||||
_push(\`<!---->\`)
|
||||
}
|
||||
@@ -110,7 +110,7 @@ describe('ssr: v-if', () => {
|
||||
"
|
||||
return function ssrRender(_ctx, _push, _parent) {
|
||||
if (_ctx.foo) {
|
||||
_push(\`<div>hi</div><div>ho</div>\`)
|
||||
_push(\`<!--1--><div>hi</div><div>ho</div><!--0-->\`)
|
||||
} else {
|
||||
_push(\`<!---->\`)
|
||||
}
|
||||
@@ -126,9 +126,11 @@ describe('ssr: v-if', () => {
|
||||
|
||||
return function ssrRender(_ctx, _push, _parent) {
|
||||
if (_ctx.foo) {
|
||||
_push(\`<!--1-->\`)
|
||||
_ssrRenderList(_ctx.list, (i) => {
|
||||
_push(\`<div></div>\`)
|
||||
})
|
||||
_push(\`<!--0-->\`)
|
||||
} else {
|
||||
_push(\`<!---->\`)
|
||||
}
|
||||
@@ -145,7 +147,7 @@ describe('ssr: v-if', () => {
|
||||
"
|
||||
return function ssrRender(_ctx, _push, _parent) {
|
||||
if (_ctx.foo) {
|
||||
_push(\`<div>hi</div><div>ho</div>\`)
|
||||
_push(\`<!--1--><div>hi</div><div>ho</div><!--0-->\`)
|
||||
} else {
|
||||
_push(\`<div></div>\`)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user