]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
wip: delete keys from props proxy when needed
authorEvan You <yyx990803@gmail.com>
Wed, 5 Jun 2019 13:38:32 +0000 (21:38 +0800)
committerEvan You <yyx990803@gmail.com>
Wed, 5 Jun 2019 13:38:32 +0000 (21:38 +0800)
packages/runtime-core/src/componentProps.ts

index 58e16fe0d6c878b8c9bc334ee9216ec9eeab10e4..06d92fb89918abd83434164d7b9e9ea65ee7fa48 100644 (file)
@@ -12,6 +12,7 @@ import {
 } from '@vue/shared'
 import { warn } from './warning'
 import { Data, ComponentInstance } from './component'
+import { FULL_PROPS } from './patchFlags'
 
 export type ComponentPropsOptions<P = Data> = {
   [K in keyof P]: Prop<P[K]> | null
@@ -147,6 +148,18 @@ export function resolveProps(
     attrs = props
   }
 
+  // in case of dynamic props, check if we need to delete keys from
+  // the props proxy
+  const { patchFlag } = instance.vnode
+  if (propsProxy !== null && (patchFlag === 0 || patchFlag & FULL_PROPS)) {
+    const rawInitialProps = unwrap(propsProxy)
+    for (const key in rawInitialProps) {
+      if (!props.hasOwnProperty(key)) {
+        delete propsProxy[key]
+      }
+    }
+  }
+
   // lock immutable
   lock()