@@ -9,15 +9,15 @@ import {
9
9
type Slots ,
10
10
type VNode ,
11
11
type VaporInteropInterface ,
12
- activate ,
13
12
createVNode ,
14
13
currentInstance ,
15
- deactivate ,
16
14
ensureRenderer ,
17
15
onScopeDispose ,
18
16
renderSlot ,
19
17
shallowRef ,
20
18
simpleSetCurrentInstance ,
19
+ activate as vdomActivate ,
20
+ deactivate as vdomDeactivate ,
21
21
} from '@vue/runtime-dom'
22
22
import {
23
23
type LooseRawProps ,
@@ -35,7 +35,12 @@ import type { RawSlots, VaporSlot } from './componentSlots'
35
35
import { renderEffect } from './renderEffect'
36
36
import { createTextNode } from './dom/node'
37
37
import { optimizePropertyLookup } from './dom/prop'
38
- import type { KeepAliveInstance } from './components/KeepAlive'
38
+ import {
39
+ type KeepAliveInstance ,
40
+ activate ,
41
+ deactivate ,
42
+ } from './components/KeepAlive'
43
+ import type { KeepAliveContext } from 'packages/runtime-core/src/components/KeepAlive'
39
44
40
45
// mounting vapor components and slots in vdom
41
46
const vaporInteropImpl : Omit <
@@ -116,6 +121,23 @@ const vaporInteropImpl: Omit<
116
121
insert ( vnode . vb || ( vnode . component as any ) , container , anchor )
117
122
insert ( vnode . anchor as any , container , anchor )
118
123
} ,
124
+
125
+ activate ( vnode , container , anchor , parentComponent ) {
126
+ const cached = ( parentComponent . ctx as KeepAliveContext ) . getCachedComponent (
127
+ vnode ,
128
+ )
129
+
130
+ vnode . el = cached . el
131
+ vnode . component = cached . component
132
+ vnode . anchor = cached . anchor
133
+ activate ( vnode . component as any , container , anchor )
134
+ insert ( vnode . anchor as any , container , anchor )
135
+ } ,
136
+
137
+ deactivate ( vnode , container ) {
138
+ deactivate ( vnode . component as any , container )
139
+ insert ( vnode . anchor as any , container )
140
+ } ,
119
141
}
120
142
121
143
const vaporSlotPropsProxyHandler : ProxyHandler <
@@ -176,7 +198,7 @@ function createVDOMComponent(
176
198
const parentInstance = currentInstance as VaporComponentInstance
177
199
const unmount = ( parentNode ?: ParentNode ) => {
178
200
if ( vnode . shapeFlag & ShapeFlags . COMPONENT_SHOULD_KEEP_ALIVE ) {
179
- deactivate (
201
+ vdomDeactivate (
180
202
vnode ,
181
203
( parentInstance as KeepAliveInstance ) . getStorageContainer ( ) ,
182
204
internals ,
@@ -190,7 +212,7 @@ function createVDOMComponent(
190
212
191
213
frag . insert = ( parentNode , anchor ) => {
192
214
if ( vnode . shapeFlag & ShapeFlags . COMPONENT_KEPT_ALIVE ) {
193
- activate (
215
+ vdomActivate (
194
216
vnode ,
195
217
parentNode ,
196
218
anchor ,
0 commit comments