Skip to content

Commit

Permalink
fix: guard against non-object provide value
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Jun 1, 2022
1 parent a00c63b commit c319cc7
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/core/instance/inject.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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++) {
Expand Down

0 comments on commit c319cc7

Please sign in to comment.