@@ -25,12 +25,6 @@ function onAnimationEnd (ev) {
2525function animate ( elem ) {
2626 if ( elem . nodeType !== 1 ) return
2727
28- const root = elem . $root
29- if ( ! root [ secret . listening ] ) {
30- root . addEventListener ( 'animationend' , onAnimationEnd , true )
31- root [ secret . listening ] = true
32- }
33-
3428 elem . $attribute ( 'enter-animation' , enterAttribute )
3529 elem . $attribute ( 'leave-animation' , leaveAttribute )
3630 elem . $attribute ( 'move-animation' , moveAttribute )
@@ -52,6 +46,7 @@ function enterAttribute (animation) {
5246 }
5347 this . style . animation = animation
5448 setAnimationDefaults ( this )
49+ registerListener ( this )
5550 }
5651}
5752
@@ -61,6 +56,15 @@ function leaveAttribute (animation) {
6156 this . $cleanup ( unwatch )
6257 this . $cleanup ( onLeave , animation )
6358 this [ secret . parent ] = this . parentNode
59+ registerListener ( this )
60+ }
61+ }
62+
63+ function registerListener ( elem ) {
64+ const root = elem . $root
65+ if ( ! root [ secret . listening ] ) {
66+ root . addEventListener ( 'animationend' , onAnimationEnd , true )
67+ root [ secret . listening ] = true
6468 }
6569}
6670
@@ -180,11 +184,11 @@ function setTransitionDefaults (elem) {
180184
181185function shouldAbsolutePosition ( elem ) {
182186 elem = elem . parentNode
183- while ( elem ) {
187+ while ( elem && elem !== elem . $root ) {
184188 if ( elem [ secret . leaving ] ) return false
185- if ( elem === elem . $root ) return true
186189 elem = elem . parentNode
187190 }
191+ return true
188192}
189193
190194function toAbsolutePosition ( elem ) {
0 commit comments