Skip to content

Commit d884232

Browse files
toBeTheLighthefeng
authored and
hefeng
committed
refactor: return is better when inject has no value (vuejs#7258)
1 parent 69f1bdc commit d884232

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/core/util/options.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,7 @@ function validatePropObject (
334334
*/
335335
function normalizeInject (options: Object, vm: ?Component) {
336336
const inject = options.inject
337+
if (!inject) return
337338
const normalized = options.inject = {}
338339
if (Array.isArray(inject)) {
339340
for (let i = 0; i < inject.length; i++) {
@@ -346,7 +347,7 @@ function normalizeInject (options: Object, vm: ?Component) {
346347
? extend({ from: key }, val)
347348
: { from: val }
348349
}
349-
} else if (process.env.NODE_ENV !== 'production' && inject) {
350+
} else if (process.env.NODE_ENV !== 'production') {
350351
warn(
351352
`Invalid value for option "inject": expected an Array or an Object, ` +
352353
`but got ${toRawType(inject)}.`,

0 commit comments

Comments
 (0)