fix(runtime-core): set appContext.provides to Object.create(null) (#781)

This commit is contained in:
djy0 2020-02-26 23:20:10 +08:00 committed by GitHub
parent 59393dd757
commit 04f83fa681
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

View File

@ -79,6 +79,9 @@ describe('api: createApp', () => {
setup() { setup() {
const foo = inject('foo') const foo = inject('foo')
const bar = inject('bar') const bar = inject('bar')
try {
inject('__proto__')
} catch (e) {}
return () => `${foo},${bar}` return () => `${foo},${bar}`
} }
} }
@ -90,6 +93,7 @@ describe('api: createApp', () => {
const root = nodeOps.createElement('div') const root = nodeOps.createElement('div')
app.mount(root) app.mount(root)
expect(serializeInner(root)).toBe(`3,2`) expect(serializeInner(root)).toBe(`3,2`)
expect('[Vue warn]: injection "__proto__" not found.').toHaveBeenWarned()
}) })
test('component', () => { test('component', () => {

View File

@ -82,7 +82,7 @@ export function createAppContext(): AppContext {
mixins: [], mixins: [],
components: {}, components: {},
directives: {}, directives: {},
provides: {} provides: Object.create(null)
} }
} }