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

This commit is contained in:
toBeTheLight 2017-12-16 14:47:44 -06:00 committed by Evan You
parent 3b7c05d0cc
commit 8be29e2f19

View File

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