File tree Expand file tree Collapse file tree 2 files changed +15
-9
lines changed Expand file tree Collapse file tree 2 files changed +15
-9
lines changed Original file line number Diff line number Diff line change @@ -2036,7 +2036,7 @@ describe('Suspense', () => {
20362036 expect ( serializeInner ( root ) ) . toBe ( `<div>sync</div>` )
20372037 } )
20382038
2039- // #10899
2039+ // #10899 / #11427
20402040 test ( 'KeepAlive + Suspense switch before branch resolves' , async ( ) => {
20412041 const Async1 = defineAsyncComponent ( {
20422042 render ( ) {
@@ -2053,14 +2053,20 @@ describe('Suspense', () => {
20532053 const root = nodeOps . createElement ( 'div' )
20542054 const App = {
20552055 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 ,
20622060 } ,
2063- } )
2061+ {
2062+ default : ( ) => {
2063+ return h ( Suspense , null , {
2064+ default : h ( components [ viewRef . value ] ) ,
2065+ fallback : h ( 'div' , 'loading' ) ,
2066+ } )
2067+ } ,
2068+ } ,
2069+ )
20642070 } ,
20652071 }
20662072 render ( h ( App ) , root )
Original file line number Diff line number Diff line change @@ -206,7 +206,7 @@ const KeepAliveImpl: ComponentOptions = {
206206
207207 function pruneCacheEntry ( key : CacheKey ) {
208208 const cached = cache . get ( key ) as VNode
209- if ( ! current || ! isSameVNodeType ( cached , current ) ) {
209+ if ( cached && ( ! current || ! isSameVNodeType ( cached , current ) ) ) {
210210 unmount ( cached )
211211 } else if ( current ) {
212212 // current active instance should no longer be kept-alive.
You can’t perform that action at this time.
0 commit comments