mirror of https://github.com/vuejs/core.git
wip: remove immutability conversion in inject
This commit is contained in:
parent
2a15491d1c
commit
c5558b7ed1
|
@ -1,6 +1,4 @@
|
||||||
import { currentInstance } from './component'
|
import { currentInstance } from './component'
|
||||||
import { immutable } from './apiReactivity'
|
|
||||||
import { isObject } from '@vue/shared'
|
|
||||||
|
|
||||||
export interface InjectionKey<T> extends Symbol {}
|
export interface InjectionKey<T> extends Symbol {}
|
||||||
|
|
||||||
|
@ -31,8 +29,8 @@ export function inject(key: InjectionKey<any> | string, defaultValue?: any) {
|
||||||
} else {
|
} else {
|
||||||
// TODO should also check for app-level provides
|
// TODO should also check for app-level provides
|
||||||
const provides = currentInstance.parent && currentInstance.provides
|
const provides = currentInstance.parent && currentInstance.provides
|
||||||
const val =
|
return provides && key in provides
|
||||||
provides && key in provides ? (provides[key as any] as any) : defaultValue
|
? (provides[key as any] as any)
|
||||||
return __DEV__ && isObject(val) ? immutable(val) : val
|
: defaultValue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue