diff --git a/packages/runtime-dom/src/components/Transition.ts b/packages/runtime-dom/src/components/Transition.ts index 825802f0..b3f9685d 100644 --- a/packages/runtime-dom/src/components/Transition.ts +++ b/packages/runtime-dom/src/components/Transition.ts @@ -37,25 +37,27 @@ export const Transition: FunctionalComponent = ( { slots } ) => h(BaseTransition, resolveTransitionProps(props), slots) +export const TransitionPropsValidators = { + ...(BaseTransition as any).props, + name: String, + type: String, + // Cannot use Boolean otherwise it will be force casted to false when + // omitted + css: null, + duration: Object, + enterFromClass: String, + enterActiveClass: String, + enterToClass: String, + appearFromClass: String, + appearActiveClass: String, + appearToClass: String, + leaveFromClass: String, + leaveActiveClass: String, + leaveToClass: String +} + if (__DEV__) { - Transition.props = { - ...(BaseTransition as any).props, - name: String, - type: String, - // Cannot use Boolean otherwise it will be force casted to false when - // omitted - css: null, - duration: Object, - enterFromClass: String, - enterActiveClass: String, - enterToClass: String, - appearFromClass: String, - appearActiveClass: String, - appearToClass: String, - leaveFromClass: String, - leaveActiveClass: String, - leaveToClass: String - } + Transition.props = TransitionPropsValidators } export function resolveTransitionProps({ diff --git a/packages/runtime-dom/src/components/TransitionGroup.ts b/packages/runtime-dom/src/components/TransitionGroup.ts index 9646b327..bd372364 100644 --- a/packages/runtime-dom/src/components/TransitionGroup.ts +++ b/packages/runtime-dom/src/components/TransitionGroup.ts @@ -4,12 +4,12 @@ import { removeTransitionClass, ElementWithTransition, getTransitionInfo, - resolveTransitionProps + resolveTransitionProps, + TransitionPropsValidators } from './Transition' import { Fragment, VNode, - Slots, warn, resolveTransitionHooks, toRaw, @@ -17,7 +17,8 @@ import { getCurrentInstance, setTransitionHooks, createVNode, - onUpdated + onUpdated, + SetupContext } from '@vue/runtime-core' interface Position { @@ -33,8 +34,8 @@ export type TransitionGroupProps = Omit & { moveClass?: string } -export const TransitionGroup = { - setup(props: TransitionGroupProps, { slots }: { slots: Slots }) { +const TransitionGroupImpl = { + setup(props: TransitionGroupProps, { slots }: SetupContext) { const instance = getCurrentInstance()! const state = useTransitionState() let prevChildren: VNode[] @@ -128,6 +129,21 @@ export const TransitionGroup = { } } +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) { if (c.el._moveCb) { c.el._moveCb()