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

Function invokeDirectiveHook

packages/runtime-core/src/directives.ts:170–200  ·  view source on GitHub ↗
(
  vnode: VNode,
  prevVNode: VNode | null,
  instance: ComponentInternalInstance | null,
  name: keyof ObjectDirective,
)

Source from the content-addressed store, hash-verified

168}
169
170export function invokeDirectiveHook(
171 vnode: VNode,
172 prevVNode: VNode | null,
173 instance: ComponentInternalInstance | null,
174 name: keyof ObjectDirective,
175): void {
176 const bindings = vnode.dirs!
177 const oldBindings = prevVNode && prevVNode.dirs!
178 for (let i = 0; i < bindings.length; i++) {
179 const binding = bindings[i]
180 if (oldBindings) {
181 binding.oldValue = oldBindings[i].value
182 }
183 let hook = binding.dir[name] as DirectiveHook | DirectiveHook[] | undefined
184 if (__COMPAT__ && !hook) {
185 hook = mapCompatDirectiveHook(name, binding.dir, instance)
186 }
187 if (hook) {
188 // disable tracking inside all lifecycle hooks
189 // since they can potentially be called inside effects.
190 pauseTracking()
191 callWithAsyncErrorHandling(hook, instance, ErrorCodes.DIRECTIVE_HOOK, [
192 vnode.el,
193 binding,
194 vnode,
195 prevVNode,
196 ])
197 resetTracking()
198 }
199 }
200}

Callers 4

mountElementFunction · 0.90
patchElementFunction · 0.90
unmountFunction · 0.90
hydrateElementFunction · 0.90

Calls 4

mapCompatDirectiveHookFunction · 0.90
pauseTrackingFunction · 0.90
resetTrackingFunction · 0.90

Tested by

no test coverage detected