wip: make injected values immutable
This commit is contained in:
parent
e53874f7e7
commit
10a2cf47ea
@ -1,4 +1,6 @@
|
|||||||
import { currentInstance } from './component'
|
import { currentInstance } from './component'
|
||||||
|
import { immutable } from './apiState'
|
||||||
|
import { isObject } from '@vue/shared'
|
||||||
|
|
||||||
export interface InjectionKey<T> extends Symbol {}
|
export interface InjectionKey<T> extends Symbol {}
|
||||||
|
|
||||||
@ -29,8 +31,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
|
||||||
return provides && key in provides
|
const val =
|
||||||
? (provides[key as any] as any)
|
provides && key in provides ? (provides[key as any] as any) : defaultValue
|
||||||
: defaultValue
|
return __DEV__ && isObject(val) ? immutable(val) : val
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user