From: Alex Snezhko Date: Wed, 23 Jul 2025 00:42:50 +0000 (-0400) Subject: dx(runtime-core): fix warning message for useSlots, useAttrs invocation with missing... X-Git-Tag: v3.5.18~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7343f7c95fdc08d0fa11a79af81311c6cbfc2282;p=thirdparty%2Fvuejs%2Fcore.git dx(runtime-core): fix warning message for useSlots, useAttrs invocation with missing instance (#13647) --- diff --git a/packages/runtime-core/src/apiSetupHelpers.ts b/packages/runtime-core/src/apiSetupHelpers.ts index 2ddaeb509a..209b3364ce 100644 --- a/packages/runtime-core/src/apiSetupHelpers.ts +++ b/packages/runtime-core/src/apiSetupHelpers.ts @@ -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)) }