File tree Expand file tree Collapse file tree 3 files changed +55
-1
lines changed
packages-private/vapor-e2e-test
packages/runtime-vapor/src/components Expand file tree Collapse file tree 3 files changed +55
-1
lines changed Original file line number Diff line number Diff line change @@ -903,7 +903,25 @@ describe('vapor transition', () => {
903903 )
904904 } )
905905
906- describe . todo ( 'transition with KeepAlive' , ( ) => { } )
906+ describe ( 'transition with KeepAlive' , ( ) => {
907+ test ( 'unmount innerChild (out-in mode)' , async ( ) => {
908+ const btnSelector = '.keep-alive > button'
909+ const containerSelector = '.keep-alive > div'
910+
911+ await transitionFinish ( )
912+ expect ( await html ( containerSelector ) ) . toBe ( '<div>0</div>' )
913+
914+ await click ( btnSelector )
915+
916+ await transitionFinish ( )
917+ expect ( await html ( containerSelector ) ) . toBe ( '' )
918+ const calls = await page ( ) . evaluate ( ( ) => {
919+ return ( window as any ) . getCalls ( 'unmount' )
920+ } )
921+ expect ( calls ) . toStrictEqual ( [ 'TrueBranch' ] )
922+ } )
923+ } )
924+
907925 describe . todo ( 'transition with Suspense' , ( ) => { } )
908926 describe . todo ( 'transition with Teleport' , ( ) => { } )
909927
Original file line number Diff line number Diff line change 77 VaporTransition ,
88 createIf ,
99 template ,
10+ onUnmounted ,
1011} from ' vue'
1112const show = ref (true )
1213const toggle = ref (true )
@@ -28,6 +29,8 @@ let calls = {
2829 showLeaveCancel: [],
2930 showAppear: [],
3031 notEnter: [],
32+
33+ unmount: [],
3134}
3235window .getCalls = key => calls[key]
3336window .resetCalls = key => (calls[key] = [])
@@ -90,6 +93,25 @@ const viewInOut = shallowRef(SimpleOne)
9093function changeViewInOut () {
9194 viewInOut .value = viewInOut .value === SimpleOne ? Two : SimpleOne
9295}
96+
97+ const TrueBranch = defineVaporComponent ({
98+ name: ' TrueBranch' ,
99+ setup () {
100+ onUnmounted (() => {
101+ calls .unmount .push (' TrueBranch' )
102+ })
103+ return template (' <div>0</div>' )()
104+ },
105+ })
106+ const includeRef = ref ([' TrueBranch' ])
107+ const click = () => {
108+ toggle .value = ! toggle .value
109+ if (toggle .value ) {
110+ includeRef .value = [' TrueBranch' ]
111+ } else {
112+ includeRef .value = []
113+ }
114+ }
93115 </script >
94116
95117<template >
@@ -481,6 +503,19 @@ function changeViewInOut() {
481503 </div >
482504 <!-- mode end -->
483505
506+ <!-- with keep-alive -->
507+ <div class =" keep-alive" >
508+ <div >
509+ <transition mode =" out-in" >
510+ <KeepAlive :include =" includeRef" >
511+ <TrueBranch v-if =" toggle" ></TrueBranch >
512+ </KeepAlive >
513+ </transition >
514+ </div >
515+ <button @click =" click" >button</button >
516+ </div >
517+ <!-- with keep-alive end -->
518+
484519 <!-- vdom interop -->
485520 <div class =" vdom" >
486521 <button @click =" toggleVdom = !toggleVdom" >toggle vdom component</button >
Original file line number Diff line number Diff line change @@ -150,6 +150,7 @@ export const VaporKeepAliveImpl: ObjectVaporComponent = defineVaporComponent({
150150 }
151151
152152 keepAliveInstance . deactivate = instance => {
153+ current = undefined
153154 deactivate ( instance , storageContainer )
154155 }
155156
You can’t perform that action at this time.
0 commit comments