Skip to content

Commit

Permalink
fix(transition): should ship props declarations in production
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Apr 7, 2020
1 parent b8da8b2 commit 4227831
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 34 deletions.
36 changes: 17 additions & 19 deletions packages/runtime-core/src/components/BaseTransition.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {
getCurrentInstance,
SetupContext,
ComponentOptions,
ComponentInternalInstance
} from '../component'
import {
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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 {
Expand Down
8 changes: 2 additions & 6 deletions packages/runtime-dom/src/components/Transition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -55,11 +55,7 @@ export const TransitionPropsValidators = {
leaveFromClass: String,
leaveActiveClass: String,
leaveToClass: String
}

if (__DEV__) {
Transition.props = TransitionPropsValidators
}
})

export function resolveTransitionProps({
name = 'v',
Expand Down
18 changes: 9 additions & 9 deletions packages/runtime-dom/src/components/TransitionGroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 4227831

Please sign in to comment.