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 () => {}
}
}
} 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