File tree Expand file tree Collapse file tree 1 file changed +15
-3
lines changed
packages/@react-aria/utils/src Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -26,7 +26,14 @@ function setupGlobalEvents() {
2626 return ;
2727 }
2828
29- let onTransitionStart = ( e : TransitionEvent ) => {
29+ function isTransitionEvent ( event : Event ) : event is TransitionEvent {
30+ return 'propertyName' in event ;
31+ }
32+
33+ let onTransitionStart = ( e : Event ) => {
34+ if ( ! isTransitionEvent ( e ) || ! e . target ) {
35+ return ;
36+ }
3037 // Add the transitioning property to the list for this element.
3138 let transitions = transitionsByElement . get ( e . target ) ;
3239 if ( ! transitions ) {
@@ -36,13 +43,18 @@ function setupGlobalEvents() {
3643 // The transitioncancel event must be registered on the element itself, rather than as a global
3744 // event. This enables us to handle when the node is deleted from the document while it is transitioning.
3845 // In that case, the cancel event would have nowhere to bubble to so we need to handle it directly.
39- e . target . addEventListener ( 'transitioncancel' , onTransitionEnd ) ;
46+ e . target . addEventListener ( 'transitioncancel' , onTransitionEnd , {
47+ once : true
48+ } ) ;
4049 }
4150
4251 transitions . add ( e . propertyName ) ;
4352 } ;
4453
45- let onTransitionEnd = ( e : TransitionEvent ) => {
54+ let onTransitionEnd = ( e : Event ) => {
55+ if ( ! isTransitionEvent ( e ) || ! e . target ) {
56+ return ;
57+ }
4658 // Remove property from list of transitioning properties.
4759 let properties = transitionsByElement . get ( e . target ) ;
4860 if ( ! properties ) {
You can’t perform that action at this time.
0 commit comments