File tree 2 files changed +38
-1
lines changed
2 files changed +38
-1
lines changed Original file line number Diff line number Diff line change 7
7
h ,
8
8
nextTick ,
9
9
nodeOps ,
10
+ onUnmounted ,
10
11
ref ,
11
12
render ,
12
13
serialize ,
@@ -768,6 +769,42 @@ describe('BaseTransition', () => {
768
769
test ( 'w/ KeepAlive' , async ( ) => {
769
770
await runTestWithKeepAlive ( testOutIn )
770
771
} )
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
+ } )
771
808
} )
772
809
773
810
// #6835
Original file line number Diff line number Diff line change @@ -254,7 +254,7 @@ const KeepAliveImpl: ComponentOptions = {
254
254
pendingCacheKey = null
255
255
256
256
if ( ! slots . default ) {
257
- return null
257
+ return ( current = null )
258
258
}
259
259
260
260
const children = slots . default ( )
You can’t perform that action at this time.
0 commit comments