Skip to content

Commit 04f83fa

Browse files
authored
fix(runtime-core): set appContext.provides to Object.create(null) (#781)
1 parent 59393dd commit 04f83fa

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

packages/runtime-core/__tests__/apiCreateApp.spec.ts

+4
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ describe('api: createApp', () => {
7979
setup() {
8080
const foo = inject('foo')
8181
const bar = inject('bar')
82+
try {
83+
inject('__proto__')
84+
} catch (e) {}
8285
return () => `${foo},${bar}`
8386
}
8487
}
@@ -90,6 +93,7 @@ describe('api: createApp', () => {
9093
const root = nodeOps.createElement('div')
9194
app.mount(root)
9295
expect(serializeInner(root)).toBe(`3,2`)
96+
expect('[Vue warn]: injection "__proto__" not found.').toHaveBeenWarned()
9397
})
9498

9599
test('component', () => {

packages/runtime-core/src/apiCreateApp.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export function createAppContext(): AppContext {
8282
mixins: [],
8383
components: {},
8484
directives: {},
85-
provides: {}
85+
provides: Object.create(null)
8686
}
8787
}
8888

0 commit comments

Comments
 (0)