fix(ssr): respect render function from extends/mixins in ssr (#3006)

fix #3004
This commit is contained in:
HcySunYang
2021-03-25 22:32:17 +08:00
committed by GitHub
parent 7fad69c260
commit 0a583d5ca2
3 changed files with 53 additions and 7 deletions

View File

@@ -670,9 +670,13 @@ function finishComponentSetup(
// template / render function normalization
if (__NODE_JS__ && isSSR) {
if (Component.render) {
instance.render = Component.render as InternalRenderFunction
}
// 1. the render function may already exist, returned by `setup`
// 2. otherwise try to use the `Component.render`
// 3. if the component doesn't have a render function,
// set `instance.render` to NOOP so that it can inherit the render function from mixins/extend
instance.render = (instance.render ||
Component.render ||
NOOP) as InternalRenderFunction
} else if (!instance.render) {
// could be set from setup()
if (compile && Component.template && !Component.render) {
@@ -711,7 +715,8 @@ function finishComponentSetup(
}
// warn missing template/render
if (__DEV__ && !Component.render && instance.render === NOOP) {
// the runtime compilation of template in SSR is done by server-render
if (__DEV__ && !Component.render && instance.render === NOOP && !isSSR) {
/* istanbul ignore if */
if (!compile && Component.template) {
warn(