Skip to content

Commit

Permalink
fix(runtime-core): avoid accidental access of Object.prototype proper…
Browse files Browse the repository at this point in the history
…ties
  • Loading branch information
yyx990803 committed Jul 2, 2020
1 parent b0fb1e0 commit f3e9c1b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
5 changes: 2 additions & 3 deletions packages/runtime-core/src/componentOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]
}
Expand Down
9 changes: 4 additions & 5 deletions packages/runtime-core/src/componentProxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down

0 comments on commit f3e9c1b

Please sign in to comment.