wip(ssr): generate correct component code

This commit is contained in:
Evan You 2020-02-06 18:03:14 -05:00
parent 7984a135ca
commit 4659c366e0
4 changed files with 27 additions and 27 deletions

View File

@ -9,10 +9,10 @@ describe('ssr: components', () => {
return function ssrRender(_ctx, _push, _parent) {
const _component_foo = resolveComponent(\\"foo\\")
_ssrRenderComponent(_component_foo, {
_push(_ssrRenderComponent(_component_foo, {
id: \\"a\\",
prop: _ctx.b
}, null, _parent)
}, null, _parent))
}"
`)
})
@ -26,7 +26,7 @@ describe('ssr: components', () => {
return function ssrRender(_ctx, _push, _parent) {
const _component_foo = resolveComponent(\\"foo\\")
_ssrRenderComponent(_component_foo, { prop: \\"b\\" }, null, _parent)
_push(_ssrRenderComponent(_component_foo, { prop: \\"b\\" }, null, _parent))
}"
`)
@ -38,10 +38,10 @@ describe('ssr: components', () => {
return function ssrRender(_ctx, _push, _parent) {
const _component_compoonent = resolveComponent(\\"compoonent\\")
_ssrRenderComponent(_component_compoonent, {
_push(_ssrRenderComponent(_component_compoonent, {
is: _ctx.foo,
prop: \\"b\\"
}, null, _parent)
}, null, _parent))
}"
`)
})
@ -55,7 +55,7 @@ describe('ssr: components', () => {
return function ssrRender(_ctx, _push, _parent) {
const _component_foo = resolveComponent(\\"foo\\")
_ssrRenderComponent(_component_foo, null, {
_push(_ssrRenderComponent(_component_foo, null, {
default: (_, _push, _parent, _scopeId) => {
if (_scopeId) {
_push(\`hello<div \${_scopeId}></div>\`)
@ -64,7 +64,7 @@ describe('ssr: components', () => {
}
},
_compiled: true
}, _parent)
}, _parent))
}"
`)
})
@ -78,12 +78,12 @@ describe('ssr: components', () => {
return function ssrRender(_ctx, _push, _parent) {
const _component_foo = resolveComponent(\\"foo\\")
_ssrRenderComponent(_component_foo, null, {
_push(_ssrRenderComponent(_component_foo, null, {
default: ({ msg }, _push, _parent, _scopeId) => {
_push(\`\${_ssrInterpolate(msg + _ctx.outer)}\`)
},
_compiled: true
}, _parent)
}, _parent))
}"
`)
})
@ -101,7 +101,7 @@ describe('ssr: components', () => {
return function ssrRender(_ctx, _push, _parent) {
const _component_foo = resolveComponent(\\"foo\\")
_ssrRenderComponent(_component_foo, null, {
_push(_ssrRenderComponent(_component_foo, null, {
default: (_, _push, _parent, _scopeId) => {
_push(\`foo\`)
},
@ -109,7 +109,7 @@ describe('ssr: components', () => {
_push(\`bar\`)
},
_compiled: true
}, _parent)
}, _parent))
}"
`)
})
@ -126,7 +126,7 @@ describe('ssr: components', () => {
return function ssrRender(_ctx, _push, _parent) {
const _component_foo = resolveComponent(\\"foo\\")
_ssrRenderComponent(_component_foo, null, createSlots({ _compiled: true }, [
_push(_ssrRenderComponent(_component_foo, null, createSlots({ _compiled: true }, [
(_ctx.ok)
? {
name: \\"named\\",
@ -135,7 +135,7 @@ describe('ssr: components', () => {
}
}
: undefined
]), _parent)
]), _parent))
}"
`)
})
@ -152,7 +152,7 @@ describe('ssr: components', () => {
return function ssrRender(_ctx, _push, _parent) {
const _component_foo = resolveComponent(\\"foo\\")
_ssrRenderComponent(_component_foo, null, createSlots({ _compiled: true }, [
_push(_ssrRenderComponent(_component_foo, null, createSlots({ _compiled: true }, [
renderList(_ctx.names, (key) => {
return {
name: key,
@ -161,7 +161,7 @@ describe('ssr: components', () => {
}
}
})
]), _parent)
]), _parent))
}"
`)
})
@ -194,7 +194,7 @@ describe('ssr: components', () => {
return function ssrRender(_ctx, _push, _parent) {
const _component_foo = resolveComponent(\\"foo\\")
_ssrRenderComponent(_component_foo, null, null, _parent)
_push(_ssrRenderComponent(_component_foo, null, null, _parent))
}"
`)

View File

@ -29,12 +29,12 @@ describe('ssr: scopeId', () => {
return function ssrRender(_ctx, _push, _parent) {
const _component_foo = resolveComponent(\\"foo\\")
_ssrRenderComponent(_component_foo, null, {
_push(_ssrRenderComponent(_component_foo, null, {
default: (_, _push, _parent, _scopeId) => {
_push(\`foo\`)
},
_compiled: true
}, _parent)
}, _parent))
}"
`)
})
@ -51,7 +51,7 @@ describe('ssr: scopeId', () => {
return function ssrRender(_ctx, _push, _parent) {
const _component_foo = resolveComponent(\\"foo\\")
_ssrRenderComponent(_component_foo, null, {
_push(_ssrRenderComponent(_component_foo, null, {
default: (_, _push, _parent, _scopeId) => {
if (_scopeId) {
_push(\`<span data-v-xxxxxxx \${_scopeId}>hello</span>\`)
@ -60,7 +60,7 @@ describe('ssr: scopeId', () => {
}
},
_compiled: true
}, _parent)
}, _parent))
}"
`)
})
@ -78,11 +78,11 @@ describe('ssr: scopeId', () => {
const _component_bar = resolveComponent(\\"bar\\")
const _component_foo = resolveComponent(\\"foo\\")
_ssrRenderComponent(_component_foo, null, {
_push(_ssrRenderComponent(_component_foo, null, {
default: (_, _push, _parent, _scopeId) => {
if (_scopeId) {
_push(\`<span data-v-xxxxxxx \${_scopeId}>hello</span>\`)
_ssrRenderComponent(_component_bar, null, {
_push(_ssrRenderComponent(_component_bar, null, {
default: (_, _push, _parent, _scopeId) => {
if (_scopeId) {
_push(\`<span data-v-xxxxxxx \${_scopeId}></span>\`)
@ -91,10 +91,10 @@ describe('ssr: scopeId', () => {
}
},
_compiled: true
}, _parent)
}, _parent))
} else {
_push(\`<span data-v-xxxxxxx>hello</span>\`)
_ssrRenderComponent(_component_bar, null, {
_push(_ssrRenderComponent(_component_bar, null, {
default: (_, _push, _parent, _scopeId) => {
if (_scopeId) {
_push(\`<span data-v-xxxxxxx \${_scopeId}></span>\`)
@ -103,11 +103,11 @@ describe('ssr: scopeId', () => {
}
},
_compiled: true
}, _parent)
}, _parent))
}
},
_compiled: true
}, _parent)
}, _parent))
}"
`)
})

View File

@ -133,6 +133,6 @@ export function ssrProcessComponent(
fn.body = processChildrenAsStatement(children, context)
}
}
context.pushStatement(node.ssrCodegenNode)
context.pushStatement(createCallExpression(`_push`, [node.ssrCodegenNode]))
}
}