mirror of https://github.com/vuejs/core.git
Merge 77893610df
into 56be3dd4db
This commit is contained in:
commit
07f9508914
|
@ -1,6 +1,5 @@
|
||||||
import { isFunction } from '@vue/shared'
|
import { isFunction } from '@vue/shared'
|
||||||
import { currentInstance } from './component'
|
import { currentInstance, getCurrentInstance } from './component'
|
||||||
import { currentRenderingInstance } from './componentRenderContext'
|
|
||||||
import { currentApp } from './apiCreateApp'
|
import { currentApp } from './apiCreateApp'
|
||||||
import { warn } from './warning'
|
import { warn } from './warning'
|
||||||
|
|
||||||
|
@ -51,7 +50,7 @@ export function inject(
|
||||||
) {
|
) {
|
||||||
// fallback to `currentRenderingInstance` so that this can be called in
|
// fallback to `currentRenderingInstance` so that this can be called in
|
||||||
// a functional component
|
// a functional component
|
||||||
const instance = currentInstance || currentRenderingInstance
|
const instance = getCurrentInstance()
|
||||||
|
|
||||||
// also support looking up from app-level provides w/ `app.runWithContext()`
|
// also support looking up from app-level provides w/ `app.runWithContext()`
|
||||||
if (instance || currentApp) {
|
if (instance || currentApp) {
|
||||||
|
@ -88,5 +87,5 @@ export function inject(
|
||||||
* user. One example is `useRoute()` in `vue-router`.
|
* user. One example is `useRoute()` in `vue-router`.
|
||||||
*/
|
*/
|
||||||
export function hasInjectionContext(): boolean {
|
export function hasInjectionContext(): boolean {
|
||||||
return !!(currentInstance || currentRenderingInstance || currentApp)
|
return !!(getCurrentInstance() || currentApp)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue