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() {
26
26
return ;
27
27
}
28
28
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
+ }
30
37
// Add the transitioning property to the list for this element.
31
38
let transitions = transitionsByElement . get ( e . target ) ;
32
39
if ( ! transitions ) {
@@ -36,13 +43,18 @@ function setupGlobalEvents() {
36
43
// The transitioncancel event must be registered on the element itself, rather than as a global
37
44
// event. This enables us to handle when the node is deleted from the document while it is transitioning.
38
45
// 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
+ } ) ;
40
49
}
41
50
42
51
transitions . add ( e . propertyName ) ;
43
52
} ;
44
53
45
- let onTransitionEnd = ( e : TransitionEvent ) => {
54
+ let onTransitionEnd = ( e : Event ) => {
55
+ if ( ! isTransitionEvent ( e ) || ! e . target ) {
56
+ return ;
57
+ }
46
58
// Remove property from list of transitioning properties.
47
59
let properties = transitionsByElement . get ( e . target ) ;
48
60
if ( ! properties ) {
You can’t perform that action at this time.
0 commit comments