File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -182,6 +182,7 @@ strats.watch = function (parentVal: ?Object, childVal: ?Object): ?Object {
182
182
*/
183
183
strats . props =
184
184
strats . methods =
185
+ strats . inject =
185
186
strats . computed = function ( parentVal : ?Object , childVal : ?Object ) : ?Object {
186
187
if ( ! childVal ) return Object . create ( parentVal || null )
187
188
if ( ! parentVal ) return childVal
@@ -247,6 +248,27 @@ function normalizeProps (options: Object) {
247
248
options . props = res
248
249
}
249
250
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
+
250
272
/**
251
273
* Normalize raw function directives into object format.
252
274
*/
@@ -280,6 +302,7 @@ export function mergeOptions (
280
302
}
281
303
282
304
normalizeProps ( child )
305
+ normalizeInject ( child )
283
306
normalizeDirectives ( child )
284
307
const extendsFrom = child . extends
285
308
if ( extendsFrom ) {
You can’t perform that action at this time.
0 commit comments