MCPcopy
hub / github.com/vuejs/core / mapCompatDirectiveHook

Function mapCompatDirectiveHook

packages/runtime-core/src/compat/customDirective.ts:26–60  ·  view source on GitHub ↗
(
  name: keyof ObjectDirective,
  dir: ObjectDirective & LegacyDirective,
  instance: ComponentInternalInstance | null,
)

Source from the content-addressed store, hash-verified

24}
25
26export function mapCompatDirectiveHook(
27 name: keyof ObjectDirective,
28 dir: ObjectDirective & LegacyDirective,
29 instance: ComponentInternalInstance | null,
30): DirectiveHook | DirectiveHook[] | undefined {
31 const mappedName = legacyDirectiveHookMap[name]
32 if (mappedName) {
33 if (isArray(mappedName)) {
34 const hook: DirectiveHook[] = []
35 mappedName.forEach(mapped => {
36 const mappedHook = dir[mapped]
37 if (mappedHook) {
38 softAssertCompatEnabled(
39 DeprecationTypes.CUSTOM_DIR,
40 instance,
41 mapped,
42 name,
43 )
44 hook.push(mappedHook)
45 }
46 })
47 return hook.length ? hook : undefined
48 } else {
49 if (dir[mappedName]) {
50 softAssertCompatEnabled(
51 DeprecationTypes.CUSTOM_DIR,
52 instance,
53 mappedName,
54 name,
55 )
56 }
57 return dir[mappedName]
58 }
59 }
60}

Callers 1

invokeDirectiveHookFunction · 0.90

Calls 3

softAssertCompatEnabledFunction · 0.90
forEachMethod · 0.80
pushMethod · 0.65

Tested by

no test coverage detected