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 {
182182 */
183183strats . props =
184184strats . methods =
185+ strats . inject =
185186strats . 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 ) {
You can’t perform that action at this time.
0 commit comments