@@ -1932,4 +1932,62 @@ describe('vdomInterop', () => {
19321932 expect ( html ( ) ) . toContain ( '<span>resolved</span>' )
19331933 } )
19341934 } )
1935+
1936+ describe ( 'KeepAlive' , ( ) => {
1937+ test ( 'should update props on reactivation of vapor child in vdom KeepAlive' , async ( ) => {
1938+ const VaporChild = defineVaporComponent ( {
1939+ props : { msg : String } ,
1940+ setup ( props : any ) {
1941+ const n0 = template ( '<div> </div>' ) ( ) as any
1942+ const x0 = child ( n0 ) as any
1943+ renderEffect ( ( ) => setText ( x0 , props . msg ) )
1944+ return n0
1945+ } ,
1946+ } )
1947+
1948+ const VdomChild = defineComponent ( {
1949+ setup ( ) {
1950+ return ( ) => h ( 'span' , 'vdom' )
1951+ } ,
1952+ } )
1953+
1954+ const current = shallowRef < any > ( VaporChild )
1955+ const msg = ref ( 'hello' )
1956+
1957+ const App = defineComponent ( {
1958+ setup ( ) {
1959+ return ( ) =>
1960+ h ( KeepAlive , null , {
1961+ default : ( ) =>
1962+ h (
1963+ resolveDynamicComponent ( current . value ) as any ,
1964+ current . value === VaporChild ? { msg : msg . value } : null ,
1965+ ) ,
1966+ } )
1967+ } ,
1968+ } )
1969+
1970+ const root = document . createElement ( 'div' )
1971+ const app = createApp ( App )
1972+ app . use ( vaporInteropPlugin )
1973+ app . mount ( root )
1974+
1975+ expect ( root . innerHTML ) . toBe ( '<div>hello</div>' )
1976+
1977+ // Switch to vdom child (deactivates vapor child)
1978+ current . value = VdomChild
1979+ await nextTick ( )
1980+ expect ( root . innerHTML ) . toBe ( '<span>vdom</span>' )
1981+
1982+ // Change props while vapor child is deactivated
1983+ msg . value = 'updated'
1984+ await nextTick ( )
1985+ expect ( root . innerHTML ) . toBe ( '<span>vdom</span>' )
1986+
1987+ // Reactivate vapor child — should reflect new props
1988+ current . value = VaporChild
1989+ await nextTick ( )
1990+ expect ( root . innerHTML ) . toBe ( '<div>updated</div>' )
1991+ } )
1992+ } )
19351993} )
0 commit comments