@@ -10,6 +10,7 @@ import {
1010 baseResolveTransitionHooks ,
1111 checkTransitionMode ,
1212 currentInstance ,
13+ getComponentName ,
1314 isTemplateNode ,
1415 leaveCbKey ,
1516 queuePostFlushCb ,
@@ -26,15 +27,17 @@ import {
2627} from '../component'
2728import { extend , isArray } from '@vue/shared'
2829import { renderEffect } from '../renderEffect'
29- import { isFragment } from '../fragment'
30+ import { type VaporFragment , isFragment } from '../fragment'
3031import {
3132 currentHydrationNode ,
3233 isHydrating ,
3334 setCurrentHydrationNode ,
3435} from '../dom/hydration'
3536
37+ const displayName = 'VaporTransition'
38+
3639const decorate = ( t : typeof VaporTransition ) => {
37- t . displayName = 'VaporTransition'
40+ t . displayName = displayName
3841 t . props = TransitionPropsValidators
3942 t . __vapor = true
4043 return t
@@ -209,10 +212,14 @@ export function applyTransitionHooks(
209212 fallthroughAttrs : boolean = true ,
210213) : VaporTransitionHooks {
211214 const isFrag = isFragment ( block )
212- const child = findTransitionBlock ( block )
213- if ( ! child ) {
215+ const child = findTransitionBlock (
216+ block ,
214217 // set transition hooks on fragment for reusing during it's updating
215- if ( isFrag ) setTransitionHooksOnFragment ( block , hooks )
218+ frag => setTransitionHooksOnFragment ( frag , hooks ) ,
219+ isFrag ,
220+ )
221+ if ( ! child ) {
222+ // if (isFrag) setTransitionHooksOnFragment(block, hooks)
216223 return hooks
217224 }
218225
@@ -290,26 +297,30 @@ export function applyTransitionLeaveHooks(
290297const transitionBlockCache = new WeakMap < Block , TransitionBlock > ( )
291298export function findTransitionBlock (
292299 block : Block ,
300+ processFragment ?: ( frag : VaporFragment ) => void ,
293301 inFragment : boolean = false ,
294302) : TransitionBlock | undefined {
295303 if ( transitionBlockCache . has ( block ) ) {
296304 return transitionBlockCache . get ( block )
297305 }
298306
299- let isFrag = false
300307 let child : TransitionBlock | undefined
301308 if ( block instanceof Node ) {
302309 // transition can only be applied on Element child
303310 if ( block instanceof Element ) child = block
304311 } else if ( isVaporComponent ( block ) ) {
305- child = findTransitionBlock ( block . block )
312+ // stop searching if encountering nested Transition component
313+ if ( getComponentName ( block . type ) === displayName ) return undefined
314+ child = findTransitionBlock ( block . block , processFragment , inFragment )
306315 // use component id as key
307316 if ( child && child . $key === undefined ) child . $key = block . uid
308317 } else if ( isArray ( block ) ) {
309318 let hasFound = false
310319 for ( const c of block ) {
311320 if ( c instanceof Comment ) continue
312- const item = findTransitionBlock ( c )
321+ // check if the child is a fragment to suppress warnings
322+ if ( isFragment ( c ) ) inFragment = true
323+ const item = findTransitionBlock ( c , processFragment , inFragment )
313324 if ( __DEV__ && hasFound ) {
314325 // warn more than one non-comment child
315326 warn (
@@ -322,15 +333,19 @@ export function findTransitionBlock(
322333 hasFound = true
323334 if ( ! __DEV__ ) break
324335 }
325- } else if ( ( isFrag = isFragment ( block ) ) ) {
336+ } else if ( isFragment ( block ) ) {
337+ // mark as in fragment to suppress warnings
338+ inFragment = true
326339 if ( block . insert ) {
327340 child = block
328341 } else {
329- child = findTransitionBlock ( block . nodes , true )
342+ processFragment && processFragment ( block )
343+ // once we encounter a fragment, we are inside a fragment
344+ child = findTransitionBlock ( block . nodes , processFragment , true )
330345 }
331346 }
332347
333- if ( __DEV__ && ! child && ! inFragment && ! isFrag ) {
348+ if ( __DEV__ && ! child && ! inFragment ) {
334349 warn ( 'Transition component has no valid child element' )
335350 }
336351
0 commit comments