From 9bddf3820e891de92d2fad2f1fa463c180631caf Mon Sep 17 00:00:00 2001 From: likui <2218301630@qq.com> Date: Tue, 21 Apr 2020 12:06:10 +0800 Subject: [PATCH 1/3] types(runtime-core): improve types for transition hook fix #1000 --- .../src/components/BaseTransition.ts | 18 +++++++++--------- packages/runtime-core/src/vnode.ts | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/packages/runtime-core/src/components/BaseTransition.ts b/packages/runtime-core/src/components/BaseTransition.ts index f643487e..6fc6411d 100644 --- a/packages/runtime-core/src/components/BaseTransition.ts +++ b/packages/runtime-core/src/components/BaseTransition.ts @@ -43,14 +43,14 @@ export interface BaseTransitionProps { onLeaveCancelled?: (el: HostElement) => void // only fired in persisted mode } -export interface TransitionHooks { +export interface TransitionHooks { persisted: boolean - beforeEnter(el: RendererElement): void - enter(el: RendererElement): void - leave(el: RendererElement, remove: () => void): void + beforeEnter(el: HostElement): void + enter(el: HostElement): void + leave(el: HostElement, remove: () => void): void afterLeave?(): void delayLeave?( - el: RendererElement, + el: HostElement, earlyRemove: () => void, delayedLeave: () => void ): void @@ -270,9 +270,9 @@ export function resolveTransitionHooks( ) } - const hooks: TransitionHooks = { + const hooks: TransitionHooks = { persisted, - beforeEnter(el: TransitionElement) { + beforeEnter(el) { if (!appear && !state.isMounted) { return } @@ -293,7 +293,7 @@ export function resolveTransitionHooks( callHook(onBeforeEnter, [el]) }, - enter(el: TransitionElement) { + enter(el) { if (!appear && !state.isMounted) { return } @@ -318,7 +318,7 @@ export function resolveTransitionHooks( } }, - leave(el: TransitionElement, remove) { + leave(el, remove) { const key = String(vnode.key) if (el._enterCb) { el._enterCb(true /* cancelled */) diff --git a/packages/runtime-core/src/vnode.ts b/packages/runtime-core/src/vnode.ts index 8f494472..07beacc5 100644 --- a/packages/runtime-core/src/vnode.ts +++ b/packages/runtime-core/src/vnode.ts @@ -107,7 +107,7 @@ export interface VNode { component: ComponentInternalInstance | null suspense: SuspenseBoundary | null dirs: DirectiveBinding[] | null - transition: TransitionHooks | null + transition: TransitionHooks | null // DOM el: HostNode | null From 63c8444d4a1b101502522d2c0f1fdf632dd638f8 Mon Sep 17 00:00:00 2001 From: underfin <2218301630@qq.com> Date: Thu, 23 Apr 2020 06:53:46 +0800 Subject: [PATCH 2/3] Update packages/runtime-core/src/components/BaseTransition.ts Co-Authored-By: Carlos Rodrigues --- packages/runtime-core/src/components/BaseTransition.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/runtime-core/src/components/BaseTransition.ts b/packages/runtime-core/src/components/BaseTransition.ts index 6fc6411d..4f0e82eb 100644 --- a/packages/runtime-core/src/components/BaseTransition.ts +++ b/packages/runtime-core/src/components/BaseTransition.ts @@ -43,7 +43,7 @@ export interface BaseTransitionProps { onLeaveCancelled?: (el: HostElement) => void // only fired in persisted mode } -export interface TransitionHooks { +export interface TransitionHooks { persisted: boolean beforeEnter(el: HostElement): void enter(el: HostElement): void