mirror of https://github.com/vuejs/core.git
fix(runtime-vapor): properly mount component only with template in production mode (#12727)
Co-authored-by: Evan You <evan@vuejs.org>
This commit is contained in:
parent
733d6fc13d
commit
568e824200
|
@ -282,6 +282,24 @@ describe('component', () => {
|
|||
expect(i.scope.effects.length).toBe(0)
|
||||
})
|
||||
|
||||
test('should mount component only with template in production mode', () => {
|
||||
__DEV__ = false
|
||||
const { component: Child } = define({
|
||||
render() {
|
||||
return template('<div> HI </div>', true)()
|
||||
},
|
||||
})
|
||||
|
||||
const { host } = define({
|
||||
setup() {
|
||||
return createComponent(Child, null, null, true)
|
||||
},
|
||||
}).render()
|
||||
|
||||
expect(host.innerHTML).toBe('<div> HI </div>')
|
||||
__DEV__ = true
|
||||
})
|
||||
|
||||
it('warn if functional vapor component not return a block', () => {
|
||||
define(() => {
|
||||
return () => {}
|
||||
|
|
|
@ -212,8 +212,18 @@ export function createComponent(
|
|||
}
|
||||
}
|
||||
} else {
|
||||
// in prod result can only be block
|
||||
instance.block = setupResult as Block
|
||||
// component has a render function but no setup function
|
||||
// (typically components with only a template and no state)
|
||||
if (!setupFn && component.render) {
|
||||
instance.block = callWithErrorHandling(
|
||||
component.render,
|
||||
instance,
|
||||
ErrorCodes.RENDER_FUNCTION,
|
||||
)
|
||||
} else {
|
||||
// in prod result can only be block
|
||||
instance.block = setupResult as Block
|
||||
}
|
||||
}
|
||||
|
||||
// single root, inherit attrs
|
||||
|
|
Loading…
Reference in New Issue