]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
refactor: migrate to getCurrentInstance API (#12958)
authorWick <wick.linxunjie@gmail.com>
Tue, 8 Jul 2025 06:30:43 +0000 (14:30 +0800)
committerGitHub <noreply@github.com>
Tue, 8 Jul 2025 06:30:43 +0000 (14:30 +0800)
packages/runtime-core/src/apiInject.ts

index 711c5d84de825b5e3087c602593c15053ff2ae6e..d5c97a52b8360d7b1d5eefbc435a5a6863841db9 100644 (file)
@@ -1,6 +1,5 @@
 import { isFunction } from '@vue/shared'
-import { currentInstance } from './component'
-import { currentRenderingInstance } from './componentRenderContext'
+import { currentInstance, getCurrentInstance } from './component'
 import { currentApp } from './apiCreateApp'
 import { warn } from './warning'
 
@@ -51,7 +50,7 @@ export function inject(
 ) {
   // fallback to `currentRenderingInstance` so that this can be called in
   // a functional component
-  const instance = currentInstance || currentRenderingInstance
+  const instance = getCurrentInstance()
 
   // also support looking up from app-level provides w/ `app.runWithContext()`
   if (instance || currentApp) {
@@ -90,5 +89,5 @@ export function inject(
  * user. One example is `useRoute()` in `vue-router`.
  */
 export function hasInjectionContext(): boolean {
-  return !!(currentInstance || currentRenderingInstance || currentApp)
+  return !!(getCurrentInstance() || currentApp)
 }