test: test suspense fallback

This commit is contained in:
Evan You
2019-09-10 11:17:26 -04:00
parent a16c87be63
commit 3959a2a2e1
2 changed files with 46 additions and 9 deletions

View File

@@ -1,5 +1,6 @@
import { VNode, normalizeVNode } from './vnode'
import { ShapeFlags } from '.'
import { isFunction } from '@vue/shared'
export const SuspenseSymbol = __DEV__ ? Symbol('Suspense key') : Symbol()
@@ -48,16 +49,16 @@ export function normalizeSuspenseChildren(
content: VNode
fallback: VNode
} {
const { shapeFlag } = vnode
const children = vnode.children as any
const { shapeFlag, children } = vnode
if (shapeFlag & ShapeFlags.SLOTS_CHILDREN) {
const { default: d, fallback } = children as any
return {
content: normalizeVNode(children.default()),
fallback: normalizeVNode(children.fallback ? children.fallback() : null)
content: normalizeVNode(isFunction(d) ? d() : d),
fallback: normalizeVNode(isFunction(fallback) ? fallback() : fallback)
}
} else {
return {
content: normalizeVNode(children),
content: normalizeVNode(children as any),
fallback: normalizeVNode(null)
}
}