File tree Expand file tree Collapse file tree 2 files changed +38
-1
lines changed Expand file tree Collapse file tree 2 files changed +38
-1
lines changed Original file line number Diff line number Diff line change 77 h ,
88 nextTick ,
99 nodeOps ,
10+ onUnmounted ,
1011 ref ,
1112 render ,
1213 serialize ,
@@ -768,6 +769,42 @@ describe('BaseTransition', () => {
768769 test ( 'w/ KeepAlive' , async ( ) => {
769770 await runTestWithKeepAlive ( testOutIn )
770771 } )
772+
773+ test ( 'w/ KeepAlive + unmount innerChild' , async ( ) => {
774+ const unmountSpy = vi . fn ( )
775+ const includeRef = ref ( [ 'TrueBranch' ] )
776+ const trueComp = {
777+ name : 'TrueBranch' ,
778+ setup ( ) {
779+ onUnmounted ( unmountSpy )
780+ const count = ref ( 0 )
781+ return ( ) => h ( 'div' , count . value )
782+ } ,
783+ }
784+
785+ const toggle = ref ( true )
786+ const { props } = mockProps ( { mode : 'out-in' } , true /*withKeepAlive*/ )
787+ const root = nodeOps . createElement ( 'div' )
788+ const App = {
789+ render ( ) {
790+ return h ( BaseTransition , props , ( ) => {
791+ return h (
792+ KeepAlive ,
793+ { include : includeRef . value } ,
794+ toggle . value ? h ( trueComp ) : h ( 'div' ) ,
795+ )
796+ } )
797+ } ,
798+ }
799+ render ( h ( App ) , root )
800+
801+ // trigger toggle
802+ toggle . value = false
803+ includeRef . value = [ ]
804+
805+ await nextTick ( )
806+ expect ( unmountSpy ) . toHaveBeenCalledTimes ( 1 )
807+ } )
771808 } )
772809
773810 // #6835
Original file line number Diff line number Diff line change @@ -254,7 +254,7 @@ const KeepAliveImpl: ComponentOptions = {
254254 pendingCacheKey = null
255255
256256 if ( ! slots . default ) {
257- return null
257+ return ( current = null )
258258 }
259259
260260 const children = slots . default ( )
You can’t perform that action at this time.
0 commit comments