mirror of https://github.com/vuejs/core.git
fix(keep-alive): fix render error in cached is undefined (#11496)
fix #11427 close #11431
This commit is contained in:
parent
6c90324870
commit
81351dc7fb
|
@ -2036,7 +2036,7 @@ describe('Suspense', () => {
|
|||
expect(serializeInner(root)).toBe(`<div>sync</div>`)
|
||||
})
|
||||
|
||||
// #10899
|
||||
// #10899 / #11427
|
||||
test('KeepAlive + Suspense switch before branch resolves', async () => {
|
||||
const Async1 = defineAsyncComponent({
|
||||
render() {
|
||||
|
@ -2053,14 +2053,20 @@ describe('Suspense', () => {
|
|||
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)
|
||||
|
|
|
@ -206,7 +206,7 @@ const KeepAliveImpl: ComponentOptions = {
|
|||
|
||||
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.
|
||||
|
|
Loading…
Reference in New Issue