Browse Source

refactor: return is better when inject has no value (#7258)

toBeTheLight 8 years ago
parent
commit
8be29e2f19
1 changed files with 2 additions and 1 deletions
  1. 2 1
      src/core/util/options.js

+ 2 - 1
src/core/util/options.js

@@ -334,6 +334,7 @@ function validatePropObject (
  */
  */
 function normalizeInject (options: Object, vm: ?Component) {
 function normalizeInject (options: Object, vm: ?Component) {
   const inject = options.inject
   const inject = options.inject
+  if (!inject) return
   const normalized = options.inject = {}
   const normalized = options.inject = {}
   if (Array.isArray(inject)) {
   if (Array.isArray(inject)) {
     for (let i = 0; i < inject.length; i++) {
     for (let i = 0; i < inject.length; i++) {
@@ -346,7 +347,7 @@ function normalizeInject (options: Object, vm: ?Component) {
         ? extend({ from: key }, val)
         ? extend({ from: key }, val)
         : { from: val }
         : { from: val }
     }
     }
-  } else if (process.env.NODE_ENV !== 'production' && inject) {
+  } else if (process.env.NODE_ENV !== 'production') {
     warn(
     warn(
       `Invalid value for option "inject": expected an Array or an Object, ` +
       `Invalid value for option "inject": expected an Array or an Object, ` +
       `but got ${toRawType(inject)}.`,
       `but got ${toRawType(inject)}.`,