Skip to content

Commit 1c4439e

Browse files
committed
simply fix inject extends
1 parent 11b7d5d commit 1c4439e

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/core/util/options.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ strats.watch = function (parentVal: ?Object, childVal: ?Object): ?Object {
182182
*/
183183
strats.props =
184184
strats.methods =
185+
strats.inject =
185186
strats.computed = function (parentVal: ?Object, childVal: ?Object): ?Object {
186187
if (!childVal) return Object.create(parentVal || null)
187188
if (!parentVal) return childVal
@@ -247,6 +248,27 @@ function normalizeProps (options: Object) {
247248
options.props = res
248249
}
249250

251+
function normalizeInject (options: Object) {
252+
const inject = options.inject
253+
if (!inject) return
254+
let res = {}
255+
let i, val
256+
if (Array.isArray(inject)) {
257+
i = inject.length
258+
while (i--) {
259+
val = inject[i]
260+
if (typeof val === 'string') {
261+
res[val] = val
262+
} else if (process.env.NODE_ENV !== 'production') {
263+
warn('inject must be strings when using array syntax.')
264+
}
265+
}
266+
} else if (isPlainObject(inject)) {
267+
res = options.inject
268+
}
269+
options.inject = res
270+
}
271+
250272
/**
251273
* Normalize raw function directives into object format.
252274
*/
@@ -280,6 +302,7 @@ export function mergeOptions (
280302
}
281303

282304
normalizeProps(child)
305+
normalizeInject(child)
283306
normalizeDirectives(child)
284307
const extendsFrom = child.extends
285308
if (extendsFrom) {

0 commit comments

Comments
 (0)