From 01a0fcb876c247235610ce549313cd829ee9e65b Mon Sep 17 00:00:00 2001 From: Evan You Date: Thu, 27 Sep 2018 10:23:31 -0400 Subject: [PATCH] fix: clone vnode before mutating flags --- packages/core/src/optional/keepAlive.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/core/src/optional/keepAlive.ts b/packages/core/src/optional/keepAlive.ts index bd5e3355..c36fc52c 100644 --- a/packages/core/src/optional/keepAlive.ts +++ b/packages/core/src/optional/keepAlive.ts @@ -1,5 +1,5 @@ import { Component, ComponentClass, MountedComponent } from '../component' -import { VNode, Slots } from '../vdom' +import { VNode, Slots, cloneVNode } from '../vdom' import { VNodeFlags } from '../flags' type MatchPattern = string | RegExp | string[] | RegExp[] @@ -81,6 +81,11 @@ export class KeepAlive extends Component<{}, KeepAliveProps> { const { cache, keys } = this const key = vnode.key == null ? comp : vnode.key const cached = cache.get(key) + + // clone vnode if it's reused because we are going to mutate its flags + if (vnode.el) { + vnode = cloneVNode(vnode) + } cache.set(key, vnode) if (cached) {