@@ -18,7 +18,6 @@ import {
18
18
invokeArrayFns
19
19
} from '@vue/shared'
20
20
import { watch } from '../apiWatch'
21
- import { SuspenseBoundary } from './Suspense'
22
21
import {
23
22
RendererInternals ,
24
23
queuePostRenderEffect ,
@@ -27,6 +26,7 @@ import {
27
26
RendererNode
28
27
} from '../renderer'
29
28
import { setTransitionHooks } from './BaseTransition'
29
+ import { ComponentPublicProxyTarget } from '../componentProxy'
30
30
31
31
type MatchPattern = string | RegExp | string [ ] | RegExp [ ]
32
32
@@ -40,9 +40,8 @@ type CacheKey = string | number | Component
40
40
type Cache = Map < CacheKey , VNode >
41
41
type Keys = Set < CacheKey >
42
42
43
- export interface KeepAliveSink {
43
+ export interface KeepAliveContext extends ComponentPublicProxyTarget {
44
44
renderer : RendererInternals
45
- parentSuspense : SuspenseBoundary | null
46
45
activate : (
47
46
vnode : VNode ,
48
47
container : RendererElement ,
@@ -76,25 +75,25 @@ const KeepAliveImpl = {
76
75
let current : VNode | null = null
77
76
78
77
const instance = getCurrentInstance ( ) !
78
+ const parentSuspense = instance . suspense
79
79
80
- // KeepAlive communicates with the instantiated renderer via the "sink"
81
- // where the renderer passes in platform-specific functions, and the
82
- // KeepAlive instance exposes activate/deactivate implementations.
80
+ // KeepAlive communicates with the instantiated renderer via the proxyTarget
81
+ // as a shared context where the renderer passes in its internals,
82
+ // and the KeepAlive instance exposes activate/deactivate implementations.
83
83
// The whole point of this is to avoid importing KeepAlive directly in the
84
84
// renderer to facilitate tree-shaking.
85
- const sink = instance . sink as KeepAliveSink
85
+ const sharedContext = instance . proxyTarget as KeepAliveContext
86
86
const {
87
87
renderer : {
88
88
p : patch ,
89
89
m : move ,
90
90
um : _unmount ,
91
91
o : { createElement }
92
- } ,
93
- parentSuspense
94
- } = sink
92
+ }
93
+ } = sharedContext
95
94
const storageContainer = createElement ( 'div' )
96
95
97
- sink . activate = ( vnode , container , anchor , isSVG , optimized ) => {
96
+ sharedContext . activate = ( vnode , container , anchor , isSVG , optimized ) => {
98
97
const child = vnode . component !
99
98
move ( vnode , container , anchor , MoveType . ENTER , parentSuspense )
100
99
// in case props have changed
@@ -116,7 +115,7 @@ const KeepAliveImpl = {
116
115
} , parentSuspense )
117
116
}
118
117
119
- sink . deactivate = ( vnode : VNode ) => {
118
+ sharedContext . deactivate = ( vnode : VNode ) => {
120
119
move ( vnode , storageContainer , null , MoveType . LEAVE , parentSuspense )
121
120
queuePostRenderEffect ( ( ) => {
122
121
const component = vnode . component !
0 commit comments