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

Function onLeave

packages/runtime-dom/src/components/Transition.ts:249–284  ·  view source on GitHub ↗
(
      el: Element & { _isLeaving?: boolean; _enterCancelled?: boolean },
      done,
    )

Source from the content-addressed store, hash-verified

247 onEnter: makeEnterHook(false),
248 onAppear: makeEnterHook(true),
249 onLeave(
250 el: Element & { _isLeaving?: boolean; _enterCancelled?: boolean },
251 done,
252 ) {
253 el._isLeaving = true
254 const resolve = () => finishLeave(el, done)
255 addTransitionClass(el, leaveFromClass)
256 if (__COMPAT__ && legacyClassEnabled && legacyLeaveFromClass) {
257 addTransitionClass(el, legacyLeaveFromClass)
258 }
259 // add *-leave-active class before reflow so in the case of a cancelled enter transition
260 // the css will not get the final state (#10677)
261 if (!el._enterCancelled) {
262 // force reflow so *-leave-from classes immediately take effect (#2593)
263 forceReflow(el)
264 addTransitionClass(el, leaveActiveClass)
265 } else {
266 addTransitionClass(el, leaveActiveClass)
267 forceReflow(el)
268 }
269 nextFrame(() => {
270 if (!el._isLeaving) {
271 // cancelled
272 return
273 }
274 removeTransitionClass(el, leaveFromClass)
275 if (__COMPAT__ && legacyClassEnabled && legacyLeaveFromClass) {
276 removeTransitionClass(el, legacyLeaveFromClass)
277 }
278 addTransitionClass(el, leaveToClass)
279 if (!hasExplicitCallback(onLeave)) {
280 whenTransitionEnds(el, type, leaveDuration, resolve)
281 }
282 })
283 callHook(onLeave, [el, resolve])
284 },
285 onEnterCancelled(el) {
286 finishEnter(el, false, undefined, true)
287 callHook(onEnterCancelled, [el])

Callers

nothing calls this directly

Calls 7

addTransitionClassFunction · 0.85
forceReflowFunction · 0.85
removeTransitionClassFunction · 0.85
hasExplicitCallbackFunction · 0.85
whenTransitionEndsFunction · 0.85
nextFrameFunction · 0.70
callHookFunction · 0.70

Tested by

no test coverage detected