fix: guard against non-object provide value

This commit is contained in:
Evan You 2022-06-01 22:18:05 +08:00
parent a00c63beb4
commit c319cc7a74

View File

@ -1,4 +1,4 @@
import { warn, hasSymbol, isFunction } from '../util/index'
import { warn, hasSymbol, isFunction, isObject } from '../util/index'
import { defineReactive, toggleObserving } from '../observer/index'
import type { Component } from 'types/component'
import { provide } from 'v3/apiInject'
@ -10,6 +10,9 @@ export function initProvide(vm: Component) {
const provided = isFunction(provideOption)
? provideOption.call(vm)
: provideOption
if (!isObject(provided)) {
return
}
const keys = hasSymbol ? Reflect.ownKeys(provided) : Object.keys(provided)
setCurrentInstance(vm)
for (let i = 0; i < keys.length; i++) {