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

Function resolveTransitionHooks

packages/runtime-core/src/components/BaseTransition.ts:332–495  ·  view source on GitHub ↗
(
  vnode: VNode,
  props: BaseTransitionProps<any>,
  state: TransitionState,
  instance: ComponentInternalInstance,
  postClone?: (hooks: TransitionHooks) => void,
)

Source from the content-addressed store, hash-verified

330// The transition hooks are attached to the vnode as vnode.transition
331// and will be called at appropriate timing in the renderer.
332export function resolveTransitionHooks(
333 vnode: VNode,
334 props: BaseTransitionProps<any>,
335 state: TransitionState,
336 instance: ComponentInternalInstance,
337 postClone?: (hooks: TransitionHooks) => void,
338): TransitionHooks {
339 const {
340 appear,
341 mode,
342 persisted = false,
343 onBeforeEnter,
344 onEnter,
345 onAfterEnter,
346 onEnterCancelled,
347 onBeforeLeave,
348 onLeave,
349 onAfterLeave,
350 onLeaveCancelled,
351 onBeforeAppear,
352 onAppear,
353 onAfterAppear,
354 onAppearCancelled,
355 } = props
356 const key = String(vnode.key)
357 const leavingVNodesCache = getLeavingNodesForType(state, vnode)
358
359 const callHook: TransitionHookCaller = (hook, args) => {
360 hook &&
361 callWithAsyncErrorHandling(
362 hook,
363 instance,
364 ErrorCodes.TRANSITION_HOOK,
365 args,
366 )
367 }
368
369 const callAsyncHook = (
370 hook: Hook<(el: any, done: () => void) => void>,
371 args: [TransitionElement, () => void],
372 ) => {
373 const done = args[1]
374 callHook(hook, args)
375 if (isArray(hook)) {
376 if (hook.every(hook => hook.length <= 1)) done()
377 } else if (hook.length <= 1) {
378 done()
379 }
380 }
381
382 const hooks: TransitionHooks<TransitionElement> = {
383 mode,
384 persisted,
385 beforeEnter(el) {
386 let hook = onBeforeEnter
387 if (!state.isMounted) {
388 if (appear) {
389 hook = onBeforeAppear || onBeforeEnter

Callers 3

setupFunction · 0.90
setupFunction · 0.85
cloneFunction · 0.85

Calls 2

StringInterface · 0.85
getLeavingNodesForTypeFunction · 0.85

Tested by

no test coverage detected