]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix: KeepAlive state should be non-reactive
authorEvan You <yyx990803@gmail.com>
Thu, 18 Oct 2018 21:49:11 +0000 (17:49 -0400)
committerEvan You <yyx990803@gmail.com>
Thu, 18 Oct 2018 21:49:11 +0000 (17:49 -0400)
packages/core/src/optional/keepAlive.ts

index fa973928d435de20c3ed8e100d127fff486de21b..8359588363b756b56cd71b4e434d92f62c0d31cc 100644 (file)
@@ -18,8 +18,13 @@ type Cache = Map<CacheKey, VNode>
 export const KeepAliveSymbol = Symbol()
 
 export class KeepAlive extends Component<KeepAliveProps> {
-  cache: Cache = new Map()
-  keys: Set<CacheKey> = new Set()
+  private cache: Cache
+  private keys: Set<CacheKey>
+
+  created() {
+    this.cache = new Map()
+    this.keys = new Set()
+  }
 
   // to be set in createRenderer when instance is created
   $unmount: (instance: ComponentInstance) => void
@@ -63,9 +68,6 @@ export class KeepAlive extends Component<KeepAliveProps> {
       }
       return children
     } else if ((vnode.flags & VNodeFlags.COMPONENT_STATEFUL) === 0) {
-      if (__DEV__) {
-        warn(`KeepAlive child must be a stateful component.`)
-      }
       return children
     }