expect(serializeInner(root)).toBe(`<div>sync</div>`)
})
- // #10899
+ // #10899 / #11427
test('KeepAlive + Suspense switch before branch resolves', async () => {
const Async1 = defineAsyncComponent({
render() {
const root = nodeOps.createElement('div')
const App = {
render() {
- return h(KeepAlive, null, {
- default: () => {
- return h(Suspense, null, {
- default: h(components[viewRef.value]),
- fallback: h('div', 'loading'),
- })
+ return h(
+ KeepAlive,
+ {
+ max: 1,
},
- })
+ {
+ default: () => {
+ return h(Suspense, null, {
+ default: h(components[viewRef.value]),
+ fallback: h('div', 'loading'),
+ })
+ },
+ },
+ )
},
}
render(h(App), root)
function pruneCacheEntry(key: CacheKey) {
const cached = cache.get(key) as VNode
- if (!current || !isSameVNodeType(cached, current)) {
+ if (cached && (!current || !isSameVNodeType(cached, current))) {
unmount(cached)
} else if (current) {
// current active instance should no longer be kept-alive.