From: Evan You Date: Thu, 2 Jul 2020 00:12:47 +0000 (-0400) Subject: fix(runtime-core): avoid accidental access of Object.prototype properties X-Git-Tag: v3.0.0-beta.18~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f3e9c1b59d5d3999ac6180ed75c84d88b29c41e6;p=thirdparty%2Fvuejs%2Fcore.git fix(runtime-core): avoid accidental access of Object.prototype properties --- diff --git a/packages/runtime-core/src/componentOptions.ts b/packages/runtime-core/src/componentOptions.ts index ee92ef521d..083a2c0d0f 100644 --- a/packages/runtime-core/src/componentOptions.ts +++ b/packages/runtime-core/src/componentOptions.ts @@ -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] } diff --git a/packages/runtime-core/src/componentProxy.ts b/packages/runtime-core/src/componentProxy.ts index 400e552158..5e3d5d1ac8 100644 --- a/packages/runtime-core/src/componentProxy.ts +++ b/packages/runtime-core/src/componentProxy.ts @@ -166,10 +166,9 @@ export type ComponentPublicInstanceConstructor< new (): T } -const publicPropertiesMap: Record< - string, - (i: ComponentInternalInstance) => any -> = { +type PublicPropertiesMap = Record 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,