feat(transition): add runtime props validation for TransitionGroup
This commit is contained in:
parent
0e3e07079a
commit
6d254da532
@ -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({
|
||||
|
@ -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<TransitionProps, 'mode'> & {
|
||||
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()
|
||||
|
Loading…
Reference in New Issue
Block a user