@@ -35,40 +35,35 @@ export const vaporTransitionImpl: VaporTransitionInterface = {
3535 warn ( `invalid <transition> mode: ${ mode } ` )
3636 }
3737
38- applyTransitionEnterHooks (
39- children ,
40- useTransitionState ( ) ,
38+ applyTransitionEnterHooks ( children , {
39+ state : useTransitionState ( ) ,
4140 props,
42- undefined ,
43- false ,
44- )
41+ } as VaporTransitionHooks )
4542
4643 return children
4744 } ,
4845}
4946
5047const getTransitionHooksContext = (
51- key : string ,
52- block : Block ,
48+ key : String ,
5349 props : TransitionProps ,
5450 state : TransitionState ,
5551 instance : GenericComponentInstance ,
5652 postClone : ( ( hooks : TransitionHooks ) => void ) | undefined ,
5753) => {
54+ const { leavingNodes } = state
5855 const context : TransitionHooksContext = {
5956 setLeavingNodeCache : el => {
60- const leavingNodeCache = getLeavingNodesForBlock ( state , block )
61- leavingNodeCache [ key ] = el
57+ leavingNodes . set ( key , el )
6258 } ,
6359 unsetLeavingNodeCache : el => {
64- const leavingNodeCache = getLeavingNodesForBlock ( state , block )
65- if ( leavingNodeCache [ key ] === el ) {
66- delete leavingNodeCache [ key ]
60+ const leavingNode = leavingNodes . get ( key )
61+ if ( leavingNode === el ) {
62+ leavingNodes . delete ( key )
6763 }
6864 } ,
6965 earlyRemove : ( ) => {
70- const leavingNodeCache = getLeavingNodesForBlock ( state , block )
71- const leavingNode = leavingNodeCache [ key ]
66+ const leavingNode = leavingNodes . get ( key )
7267 if ( leavingNode && ( leavingNode as TransitionElement ) [ leaveCbKey ] ) {
7368 // force early removal (not cancelled)
7469 ; ( leavingNode as TransitionElement ) [ leaveCbKey ] ! ( )
@@ -96,39 +91,24 @@ function resolveTransitionHooks(
9691 instance : GenericComponentInstance ,
9792 postClone ?: ( hooks : TransitionHooks ) => void ,
9893) : VaporTransitionHooks {
99- const key = String ( block . key )
10094 const context = getTransitionHooksContext (
101- key ,
102- block ,
95+ String ( block . key ) ,
10396 props ,
10497 state ,
10598 instance ,
10699 postClone ,
107100 )
108- const hooks : VaporTransitionHooks = baseResolveTransitionHooks (
101+ const hooks = baseResolveTransitionHooks (
109102 context ,
110103 props ,
111104 state ,
112105 instance ,
113- )
106+ ) as VaporTransitionHooks
114107 hooks . state = state
115108 hooks . props = props
116109 return hooks
117110}
118111
119- function getLeavingNodesForBlock (
120- state : TransitionState ,
121- block : Block ,
122- ) : Record < string , Block > {
123- const { leavingVNodes } = state
124- let leavingNodesCache = leavingVNodes . get ( block ) !
125- if ( ! leavingNodesCache ) {
126- leavingNodesCache = Object . create ( null )
127- leavingVNodes . set ( block , leavingNodesCache )
128- }
129- return leavingNodesCache
130- }
131-
132112function setTransitionHooks ( block : Block , hooks : VaporTransitionHooks ) {
133113 if ( ! isFragment ( block ) ) {
134114 block . transition = hooks
@@ -137,28 +117,20 @@ function setTransitionHooks(block: Block, hooks: VaporTransitionHooks) {
137117
138118export function applyTransitionEnterHooks (
139119 block : Block ,
140- state : TransitionState ,
141- props : TransitionProps ,
142- enterHooks ?: VaporTransitionHooks ,
143- clone : boolean = true ,
120+ hooks : VaporTransitionHooks ,
144121) : Block | undefined {
145122 const child = findElementChild ( block )
146123 if ( child ) {
147- if ( ! enterHooks ) {
148- enterHooks = resolveTransitionHooks (
149- child ,
150- props ,
151- state ,
152- currentInstance ! ,
153- hooks => ( enterHooks = hooks ) ,
154- )
155- }
156-
157- setTransitionHooks (
124+ const { props, state, delayedLeave } = hooks
125+ let enterHooks = resolveTransitionHooks (
158126 child ,
159- clone ? enterHooks . clone ( child as any ) : enterHooks ,
127+ props ,
128+ state ,
129+ currentInstance ! ,
130+ hooks => ( enterHooks = hooks as VaporTransitionHooks ) ,
160131 )
161-
132+ enterHooks . delayedLeave = delayedLeave
133+ setTransitionHooks ( child , enterHooks )
162134 if ( isFragment ( block ) ) {
163135 block . transitionChild = child
164136 }
@@ -168,15 +140,14 @@ export function applyTransitionEnterHooks(
168140
169141export function applyTransitionLeaveHooks (
170142 block : Block ,
171- state : TransitionState ,
172- props : TransitionProps ,
143+ enterHooks : VaporTransitionHooks ,
173144 afterLeaveCb : ( ) => void ,
174- enterHooks : TransitionHooks ,
175145) : void {
176146 const leavingBlock = findElementChild ( block )
177147 if ( ! leavingBlock ) return undefined
178148
179- let leavingHooks = resolveTransitionHooks (
149+ const { props, state } = enterHooks
150+ const leavingHooks = resolveTransitionHooks (
180151 leavingBlock ,
181152 props ,
182153 state ,
@@ -198,8 +169,7 @@ export function applyTransitionLeaveHooks(
198169 earlyRemove ,
199170 delayedLeave ,
200171 ) => {
201- const leavingNodeCache = getLeavingNodesForBlock ( state , leavingBlock )
202- leavingNodeCache [ String ( leavingBlock . key ) ] = leavingBlock
172+ state . leavingNodes . set ( String ( leavingBlock . key ) , leavingBlock )
203173 // early removal callback
204174 block [ leaveCbKey ] = ( ) => {
205175 earlyRemove ( )
0 commit comments