@@ -22,7 +22,7 @@ import {
2222 isFragment ,
2323} from '../block'
2424import { type VaporComponentInstance , isVaporComponent } from '../component'
25- import { isArray } from '@vue/shared'
25+ import { extend , isArray } from '@vue/shared'
2626import { renderEffect } from '../renderEffect'
2727import { setDynamicProps } from '../dom/prop'
2828
@@ -34,10 +34,11 @@ const decorate = (t: typeof VaporTransition) => {
3434}
3535
3636export const VaporTransition : FunctionalComponent < TransitionProps > =
37- /*@__PURE__ */ decorate ( ( props , { slots } ) => {
37+ /*@__PURE__ */ decorate ( ( props , { slots, attrs } ) => {
3838 const children = ( slots . default && slots . default ( ) ) as any as Block
3939 if ( ! children ) return
4040
41+ const instance = currentInstance ! as VaporComponentInstance
4142 const { mode } = props
4243 checkTransitionMode ( mode )
4344
@@ -48,27 +49,45 @@ export const VaporTransition: FunctionalComponent<TransitionProps> =
4849 if ( isMounted ) {
4950 // only update props for Fragment block, for later reusing
5051 if ( isFragment ( children ) ) {
51- if ( children . $transition ) {
52- children . $transition . props = resolvedProps
53- }
52+ children . $transition ! . props = resolvedProps
5453 } else {
55- // replace existing transition hooks
5654 const child = findTransitionBlock ( children )
57- if ( child && child . $transition ) {
58- child . $transition . props = resolvedProps
59- applyTransitionHooks ( child , child . $transition )
55+ if ( child ) {
56+ // replace existing transition hooks
57+ child . $transition ! . props = resolvedProps
58+ applyTransitionHooks ( child , child . $transition ! )
6059 }
6160 }
6261 } else {
6362 isMounted = true
6463 }
6564 } )
6665
67- applyTransitionHooks ( children , {
68- state : useTransitionState ( ) ,
69- props : resolvedProps ! ,
70- instance : currentInstance ! ,
71- } as VaporTransitionHooks )
66+ // fallthrough attrs
67+ let fallthroughAttrs = true
68+ if ( instance . hasFallthrough ) {
69+ renderEffect ( ( ) => {
70+ // attrs are accessed in advance
71+ const resolvedAttrs = extend ( { } , attrs )
72+ const child = findTransitionBlock ( children )
73+ if ( child ) {
74+ setDynamicProps ( child , [ resolvedAttrs ] )
75+ // ensure fallthrough attrs are not happened again in
76+ // applyTransitionHooks
77+ fallthroughAttrs = false
78+ }
79+ } )
80+ }
81+
82+ applyTransitionHooks (
83+ children ,
84+ {
85+ state : useTransitionState ( ) ,
86+ props : resolvedProps ! ,
87+ instance : instance ,
88+ } as VaporTransitionHooks ,
89+ fallthroughAttrs ,
90+ )
7291
7392 return children
7493 } )
@@ -164,7 +183,6 @@ export function applyTransitionHooks(
164183 setTransitionHooks ( child , resolvedHooks )
165184 if ( isFrag ) setTransitionHooksToFragment ( block , resolvedHooks )
166185
167- // TODO handle attrs update
168186 // fallthrough attrs
169187 if ( fallthroughAttrs && instance . hasFallthrough ) {
170188 setDynamicProps ( child , [ instance . attrs ] )
0 commit comments