]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix(runtime-core): avoid accidental access of Object.prototype properties
authorEvan You <yyx990803@gmail.com>
Thu, 2 Jul 2020 00:12:47 +0000 (20:12 -0400)
committerEvan You <yyx990803@gmail.com>
Thu, 2 Jul 2020 00:13:02 +0000 (20:13 -0400)
packages/runtime-core/src/componentOptions.ts
packages/runtime-core/src/componentProxy.ts

index ee92ef521d0af2694f5ba6e6fb7becefa0a0e88e..083a2c0d0f7434f1614de38e15fea72fd3ecf6e7 100644 (file)
@@ -723,9 +723,8 @@ export function resolveMergedOptions(
 function mergeOptions(to: any, from: any, instance: ComponentInternalInstance) {
   const strats = instance.appContext.config.optionMergeStrategies
   for (const key in from) {
-    const strat = strats && strats[key]
-    if (strat) {
-      to[key] = strat(to[key], from[key], instance.proxy, key)
+    if (strats && hasOwn(strats, key)) {
+      to[key] = strats[key](to[key], from[key], instance.proxy, key)
     } else if (!hasOwn(to, key)) {
       to[key] = from[key]
     }
index 400e552158390de098de82535a0caf1a4aec6844..5e3d5d1ac85e838b0c9ac762652a3126df887e70 100644 (file)
@@ -166,10 +166,9 @@ export type ComponentPublicInstanceConstructor<
   new (): T
 }
 
-const publicPropertiesMap: Record<
-  string,
-  (i: ComponentInternalInstance) => any
-> = {
+type PublicPropertiesMap = Record<string, (i: ComponentInternalInstance) => any>
+
+const publicPropertiesMap: PublicPropertiesMap = extend(Object.create(null), {
   $: i => i,
   $el: i => i.vnode.el,
   $data: i => i.data,
@@ -184,7 +183,7 @@ const publicPropertiesMap: Record<
   $forceUpdate: i => () => queueJob(i.update),
   $nextTick: () => nextTick,
   $watch: __FEATURE_OPTIONS__ ? i => instanceWatch.bind(i) : NOOP
-}
+} as PublicPropertiesMap)
 
 const enum AccessTypes {
   SETUP,