@@ -18,7 +18,6 @@ import {
1818 invokeArrayFns
1919} from '@vue/shared'
2020import { watch } from '../apiWatch'
21- import { SuspenseBoundary } from './Suspense'
2221import {
2322 RendererInternals ,
2423 queuePostRenderEffect ,
@@ -27,6 +26,7 @@ import {
2726 RendererNode
2827} from '../renderer'
2928import { setTransitionHooks } from './BaseTransition'
29+ import { ComponentPublicProxyTarget } from '../componentProxy'
3030
3131type MatchPattern = string | RegExp | string [ ] | RegExp [ ]
3232
@@ -40,9 +40,8 @@ type CacheKey = string | number | Component
4040type Cache = Map < CacheKey , VNode >
4141type Keys = Set < CacheKey >
4242
43- export interface KeepAliveSink {
43+ export interface KeepAliveContext extends ComponentPublicProxyTarget {
4444 renderer : RendererInternals
45- parentSuspense : SuspenseBoundary | null
4645 activate : (
4746 vnode : VNode ,
4847 container : RendererElement ,
@@ -76,25 +75,25 @@ const KeepAliveImpl = {
7675 let current : VNode | null = null
7776
7877 const instance = getCurrentInstance ( ) !
78+ const parentSuspense = instance . suspense
7979
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.
8383 // The whole point of this is to avoid importing KeepAlive directly in the
8484 // renderer to facilitate tree-shaking.
85- const sink = instance . sink as KeepAliveSink
85+ const sharedContext = instance . proxyTarget as KeepAliveContext
8686 const {
8787 renderer : {
8888 p : patch ,
8989 m : move ,
9090 um : _unmount ,
9191 o : { createElement }
92- } ,
93- parentSuspense
94- } = sink
92+ }
93+ } = sharedContext
9594 const storageContainer = createElement ( 'div' )
9695
97- sink . activate = ( vnode , container , anchor , isSVG , optimized ) => {
96+ sharedContext . activate = ( vnode , container , anchor , isSVG , optimized ) => {
9897 const child = vnode . component !
9998 move ( vnode , container , anchor , MoveType . ENTER , parentSuspense )
10099 // in case props have changed
@@ -116,7 +115,7 @@ const KeepAliveImpl = {
116115 } , parentSuspense )
117116 }
118117
119- sink . deactivate = ( vnode : VNode ) => {
118+ sharedContext . deactivate = ( vnode : VNode ) => {
120119 move ( vnode , storageContainer , null , MoveType . LEAVE , parentSuspense )
121120 queuePostRenderEffect ( ( ) => {
122121 const component = vnode . component !
0 commit comments