import { setCurrentRenderingInstance } from './componentRenderContext'
import { isVNode, normalizeVNode } from './vnode'
import { ensureValidVNode } from './helpers/renderSlot'
+import { popWarningContext, pushWarningContext } from './warning'
const _ssrUtils: {
createComponentInstance: typeof createComponentInstance
normalizeVNode: typeof normalizeVNode
getComponentPublicInstance: typeof getComponentPublicInstance
ensureValidVNode: typeof ensureValidVNode
+ pushWarningContext: typeof pushWarningContext
+ popWarningContext: typeof popWarningContext
} = {
createComponentInstance,
setupComponent,
normalizeVNode,
getComponentPublicInstance,
ensureValidVNode,
+ pushWarningContext,
+ popWarningContext,
}
/**
expect(html).toBe(`<div>foo</div>`)
})
+ test('warnings should be suppressed by app.config.warnHandler', async () => {
+ const app = createApp({
+ render() {
+ return h('div', this.foo)
+ },
+ })
+ app.config.warnHandler = vi.fn()
+ await render(app)
+ expect('not defined on instance').not.toHaveBeenWarned()
+ expect(app.config.warnHandler).toHaveBeenCalledTimes(1)
+ })
+
describe('components', () => {
test('vnode components', async () => {
expect(
setupComponent,
renderComponentRoot,
normalizeVNode,
+ pushWarningContext,
+ popWarningContext,
} = ssrUtils
export type SSRBuffer = SSRBufferItem[] & { hasAsync?: boolean }
parentComponent: ComponentInternalInstance | null = null,
slotScopeId?: string,
): SSRBuffer | Promise<SSRBuffer> {
- const instance = createComponentInstance(vnode, parentComponent, null)
+ const instance = (vnode.component = createComponentInstance(
+ vnode,
+ parentComponent,
+ null,
+ ))
+ if (__DEV__) pushWarningContext(vnode)
const res = setupComponent(instance, true /* isSSR */)
+ if (__DEV__) popWarningContext()
const hasAsyncSetup = isPromise(res)
let prefetches = instance.sp /* LifecycleHooks.SERVER_PREFETCH */
if (hasAsyncSetup || prefetches) {
instance: ComponentInternalInstance,
slotScopeId?: string,
): SSRBuffer | Promise<SSRBuffer> {
+ if (__DEV__) pushWarningContext(instance.vnode)
const comp = instance.type as Component
const { getBuffer, push } = createBuffer()
if (isFunction(comp)) {
push(`<!---->`)
}
}
+ if (__DEV__) popWarningContext()
return getBuffer()
}