fix(transition): should ship props declarations in production

This commit is contained in:
Evan You 2020-04-07 17:19:37 -04:00
parent b8da8b2dfa
commit 42278317e1
3 changed files with 28 additions and 34 deletions

View File

@ -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 {

View File

@ -37,7 +37,7 @@ export const Transition: FunctionalComponent<TransitionProps> = (
{ 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',

View File

@ -36,6 +36,12 @@ export type TransitionGroupProps = Omit<TransitionProps, 'mode'> & {
}
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) {