]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
chore: comments explaining keep-alive implementation details [ci skip]
authorEvan You <yyx990803@gmail.com>
Thu, 31 Oct 2019 16:41:28 +0000 (12:41 -0400)
committerEvan You <yyx990803@gmail.com>
Thu, 31 Oct 2019 16:41:28 +0000 (12:41 -0400)
packages/runtime-core/src/keepAlive.ts

index f86b9263559cdfee4f96d38976491d98c918f1f7..bdbff8a80806f66469b2c5102bc7ad31f8fe899f 100644 (file)
@@ -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: {