From 42278317e15a202e4e1c8f7084eafa7bb13f1ade Mon Sep 17 00:00:00 2001 From: Evan You Date: Tue, 7 Apr 2020 17:19:37 -0400 Subject: [PATCH] fix(transition): should ship props declarations in production --- .../src/components/BaseTransition.ts | 36 +++++++++---------- .../runtime-dom/src/components/Transition.ts | 8 ++--- .../src/components/TransitionGroup.ts | 18 +++++----- 3 files changed, 28 insertions(+), 34 deletions(-) diff --git a/packages/runtime-core/src/components/BaseTransition.ts b/packages/runtime-core/src/components/BaseTransition.ts index f516ad92..f643487e 100644 --- a/packages/runtime-core/src/components/BaseTransition.ts +++ b/packages/runtime-core/src/components/BaseTransition.ts @@ -1,7 +1,6 @@ import { getCurrentInstance, SetupContext, - ComponentOptions, ComponentInternalInstance } from '../component' import { @@ -100,6 +99,23 @@ export function useTransitionState(): TransitionState { const BaseTransitionImpl = { name: `BaseTransition`, + + props: { + mode: String, + appear: Boolean, + persisted: Boolean, + // enter + onBeforeEnter: Function, + onEnter: Function, + onAfterEnter: Function, + onEnterCancelled: Function, + // leave + onBeforeLeave: Function, + onLeave: Function, + onAfterLeave: Function, + onLeaveCancelled: Function + }, + setup(props: BaseTransitionProps, { slots }: SetupContext) { const instance = getCurrentInstance()! const state = useTransitionState() @@ -201,24 +217,6 @@ const BaseTransitionImpl = { } } -if (__DEV__) { - ;(BaseTransitionImpl as ComponentOptions).props = { - mode: String, - appear: Boolean, - persisted: Boolean, - // enter - onBeforeEnter: Function, - onEnter: Function, - onAfterEnter: Function, - onEnterCancelled: Function, - // leave - onBeforeLeave: Function, - onLeave: Function, - onAfterLeave: Function, - onLeaveCancelled: Function - } -} - // export the public type for h/tsx inference // also to avoid inline import() in generated d.ts files export const BaseTransition = (BaseTransitionImpl as any) as { diff --git a/packages/runtime-dom/src/components/Transition.ts b/packages/runtime-dom/src/components/Transition.ts index d80d4f9e..67c85d00 100644 --- a/packages/runtime-dom/src/components/Transition.ts +++ b/packages/runtime-dom/src/components/Transition.ts @@ -37,7 +37,7 @@ export const Transition: FunctionalComponent = ( { slots } ) => h(BaseTransition, resolveTransitionProps(props), slots) -export const TransitionPropsValidators = { +export const TransitionPropsValidators = (Transition.props = { ...(BaseTransition as any).props, name: String, type: String, @@ -55,11 +55,7 @@ export const TransitionPropsValidators = { leaveFromClass: String, leaveActiveClass: String, leaveToClass: String -} - -if (__DEV__) { - Transition.props = TransitionPropsValidators -} +}) export function resolveTransitionProps({ name = 'v', diff --git a/packages/runtime-dom/src/components/TransitionGroup.ts b/packages/runtime-dom/src/components/TransitionGroup.ts index 331b5f19..24d23b9e 100644 --- a/packages/runtime-dom/src/components/TransitionGroup.ts +++ b/packages/runtime-dom/src/components/TransitionGroup.ts @@ -36,6 +36,12 @@ export type TransitionGroupProps = Omit & { } const TransitionGroupImpl = { + props: { + ...TransitionPropsValidators, + tag: String, + moveClass: String + }, + setup(props: TransitionGroupProps, { slots }: SetupContext) { const instance = getCurrentInstance()! const state = useTransitionState() @@ -130,21 +136,15 @@ const TransitionGroupImpl = { } } +// remove mode props as TransitionGroup doesn't support it +delete TransitionGroupImpl.props.mode + export const TransitionGroup = (TransitionGroupImpl as unknown) as { new (): { $props: TransitionGroupProps } } -if (__DEV__) { - const props = ((TransitionGroup as any).props = { - ...TransitionPropsValidators, - tag: String, - moveClass: String - }) - delete props.mode -} - function callPendingCbs(c: VNode) { const el = c.el as any if (el._moveCb) {