File tree 2 files changed +15
-9
lines changed
2 files changed +15
-9
lines changed Original file line number Diff line number Diff line change @@ -2036,7 +2036,7 @@ describe('Suspense', () => {
2036
2036
expect ( serializeInner ( root ) ) . toBe ( `<div>sync</div>` )
2037
2037
} )
2038
2038
2039
- // #10899
2039
+ // #10899 / #11427
2040
2040
test ( 'KeepAlive + Suspense switch before branch resolves' , async ( ) => {
2041
2041
const Async1 = defineAsyncComponent ( {
2042
2042
render ( ) {
@@ -2053,14 +2053,20 @@ describe('Suspense', () => {
2053
2053
const root = nodeOps . createElement ( 'div' )
2054
2054
const App = {
2055
2055
render ( ) {
2056
- return h ( KeepAlive , null , {
2057
- default : ( ) => {
2058
- return h ( Suspense , null , {
2059
- default : h ( components [ viewRef . value ] ) ,
2060
- fallback : h ( 'div' , 'loading' ) ,
2061
- } )
2056
+ return h (
2057
+ KeepAlive ,
2058
+ {
2059
+ max : 1 ,
2062
2060
} ,
2063
- } )
2061
+ {
2062
+ default : ( ) => {
2063
+ return h ( Suspense , null , {
2064
+ default : h ( components [ viewRef . value ] ) ,
2065
+ fallback : h ( 'div' , 'loading' ) ,
2066
+ } )
2067
+ } ,
2068
+ } ,
2069
+ )
2064
2070
} ,
2065
2071
}
2066
2072
render ( h ( App ) , root )
Original file line number Diff line number Diff line change @@ -206,7 +206,7 @@ const KeepAliveImpl: ComponentOptions = {
206
206
207
207
function pruneCacheEntry ( key : CacheKey ) {
208
208
const cached = cache . get ( key ) as VNode
209
- if ( ! current || ! isSameVNodeType ( cached , current ) ) {
209
+ if ( cached && ( ! current || ! isSameVNodeType ( cached , current ) ) ) {
210
210
unmount ( cached )
211
211
} else if ( current ) {
212
212
// current active instance should no longer be kept-alive.
You can’t perform that action at this time.
0 commit comments