Skip to content

Commit f3e9c1b

Browse files
committed
fix(runtime-core): avoid accidental access of Object.prototype properties
1 parent b0fb1e0 commit f3e9c1b

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

packages/runtime-core/src/componentOptions.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -723,9 +723,8 @@ export function resolveMergedOptions(
723723
function mergeOptions(to: any, from: any, instance: ComponentInternalInstance) {
724724
const strats = instance.appContext.config.optionMergeStrategies
725725
for (const key in from) {
726-
const strat = strats && strats[key]
727-
if (strat) {
728-
to[key] = strat(to[key], from[key], instance.proxy, key)
726+
if (strats && hasOwn(strats, key)) {
727+
to[key] = strats[key](to[key], from[key], instance.proxy, key)
729728
} else if (!hasOwn(to, key)) {
730729
to[key] = from[key]
731730
}

packages/runtime-core/src/componentProxy.ts

+4-5
Original file line numberDiff line numberDiff line change
@@ -166,10 +166,9 @@ export type ComponentPublicInstanceConstructor<
166166
new (): T
167167
}
168168

169-
const publicPropertiesMap: Record<
170-
string,
171-
(i: ComponentInternalInstance) => any
172-
> = {
169+
type PublicPropertiesMap = Record<string, (i: ComponentInternalInstance) => any>
170+
171+
const publicPropertiesMap: PublicPropertiesMap = extend(Object.create(null), {
173172
$: i => i,
174173
$el: i => i.vnode.el,
175174
$data: i => i.data,
@@ -184,7 +183,7 @@ const publicPropertiesMap: Record<
184183
$forceUpdate: i => () => queueJob(i.update),
185184
$nextTick: () => nextTick,
186185
$watch: __FEATURE_OPTIONS__ ? i => instanceWatch.bind(i) : NOOP
187-
}
186+
} as PublicPropertiesMap)
188187

189188
const enum AccessTypes {
190189
SETUP,

0 commit comments

Comments
 (0)