]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
dx(runtime-core): fix warning message for useSlots, useAttrs invocation with missing...
authorAlex Snezhko <alexsnezhko89@gmail.com>
Wed, 23 Jul 2025 00:42:50 +0000 (20:42 -0400)
committerGitHub <noreply@github.com>
Wed, 23 Jul 2025 00:42:50 +0000 (08:42 +0800)
packages/runtime-core/src/apiSetupHelpers.ts

index 2ddaeb509ad7c2a418e6f852f97924ba7fddec3a..209b3364ceca3f2b56400cb483ac304ffe0bdd67 100644 (file)
@@ -382,17 +382,17 @@ export function withDefaults<
 }
 
 export function useSlots(): SetupContext['slots'] {
-  return getContext().slots
+  return getContext('useSlots').slots
 }
 
 export function useAttrs(): SetupContext['attrs'] {
-  return getContext().attrs
+  return getContext('useAttrs').attrs
 }
 
-function getContext(): SetupContext {
+function getContext(calledFunctionName: string): SetupContext {
   const i = getCurrentInstance()!
   if (__DEV__ && !i) {
-    warn(`useContext() called without active instance.`)
+    warn(`${calledFunctionName}() called without active instance.`)
   }
   return i.setupContext || (i.setupContext = createSetupContext(i))
 }