( vnode: VNode, prevVNode: VNode | null, instance: ComponentInternalInstance | null, name: keyof ObjectDirective, )
| 168 | } |
| 169 | |
| 170 | export 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 | } |
no test coverage detected