Skip to content

Commit c319cc7

Browse files
committed
fix: guard against non-object provide value
1 parent a00c63b commit c319cc7

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/core/instance/inject.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { warn, hasSymbol, isFunction } from '../util/index'
1+
import { warn, hasSymbol, isFunction, isObject } from '../util/index'
22
import { defineReactive, toggleObserving } from '../observer/index'
33
import type { Component } from 'types/component'
44
import { provide } from 'v3/apiInject'
@@ -10,6 +10,9 @@ export function initProvide(vm: Component) {
1010
const provided = isFunction(provideOption)
1111
? provideOption.call(vm)
1212
: provideOption
13+
if (!isObject(provided)) {
14+
return
15+
}
1316
const keys = hasSymbol ? Reflect.ownKeys(provided) : Object.keys(provided)
1417
setCurrentInstance(vm)
1518
for (let i = 0; i < keys.length; i++) {

0 commit comments

Comments
 (0)