From: Evan You Date: Thu, 31 Oct 2019 16:41:28 +0000 (-0400) Subject: chore: comments explaining keep-alive implementation details [ci skip] X-Git-Tag: v3.0.0-alpha.0~270 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b114cdf6ee3ad2c351fe8fc7c905ca2d60088547;p=thirdparty%2Fvuejs%2Fcore.git chore: comments explaining keep-alive implementation details [ci skip] --- diff --git a/packages/runtime-core/src/keepAlive.ts b/packages/runtime-core/src/keepAlive.ts index f86b926355..bdbff8a808 100644 --- a/packages/runtime-core/src/keepAlive.ts +++ b/packages/runtime-core/src/keepAlive.ts @@ -41,13 +41,24 @@ export interface KeepAliveSink { export const KeepAlive = { name: `KeepAlive`, + + // Marker for special handling inside the renderer. We are not using a === + // check directly on KeepAlive in the renderer, because importing it directly + // would prevent it from being tree-shaken. __isKeepAlive: true, + setup(props: KeepAliveProps, { slots }: SetupContext) { const cache: Cache = new Map() const keys: Keys = new Set() let current: VNode | null = null const instance = getCurrentInstance()! + + // KeepAlive communicates with the instantiated renderer via the "sink" + // where the renderer passes in platform-specific functions, and the + // KeepAlivei instance expses activcate/decativate implementations. + // The whole point of this is to avoid importing KeepAlive directly in the + // renderer to facilitate tree-shaking. const sink = instance.sink as KeepAliveSink const { renderer: {