@@ -554,9 +554,13 @@ function leverageNative( el, type, expectSync ) {
554554 if ( ( event . isTrigger & 1 ) && this [ type ] ) {
555555
556556 // Interrupt processing of the outer synthetic .trigger()ed event
557- if ( ! saved ) {
557+ // Saved data should be false in such cases, but might be a leftover capture object
558+ // from an async native handler (gh-4350)
559+ if ( ! saved . length ) {
558560
559561 // Store arguments for use when handling the inner native event
562+ // There will always be at least one argument (an event object), so this array
563+ // will not be confused with a leftover capture object.
560564 saved = slice . call ( arguments ) ;
561565 dataPriv . set ( this , type , saved ) ;
562566
@@ -569,14 +573,14 @@ function leverageNative( el, type, expectSync ) {
569573 if ( saved !== result || notAsync ) {
570574 dataPriv . set ( this , type , false ) ;
571575 } else {
572- result = undefined ;
576+ result = { } ;
573577 }
574578 if ( saved !== result ) {
575579
576580 // Cancel the outer synthetic event
577581 event . stopImmediatePropagation ( ) ;
578582 event . preventDefault ( ) ;
579- return result ;
583+ return result . value ;
580584 }
581585
582586 // If this is an inner synthetic event for an event with a bubbling surrogate
@@ -591,17 +595,19 @@ function leverageNative( el, type, expectSync ) {
591595
592596 // If this is a native event triggered above, everything is now in order
593597 // Fire an inner synthetic event with the original arguments
594- } else if ( saved ) {
598+ } else if ( saved . length ) {
595599
596600 // ...and capture the result
597- dataPriv . set ( this , type , jQuery . event . trigger (
598-
599- // Support: IE <=9 - 11+
600- // Extend with the prototype to reset the above stopImmediatePropagation()
601- jQuery . extend ( saved . shift ( ) , jQuery . Event . prototype ) ,
602- saved ,
603- this
604- ) ) ;
601+ dataPriv . set ( this , type , {
602+ value : jQuery . event . trigger (
603+
604+ // Support: IE <=9 - 11+
605+ // Extend with the prototype to reset the above stopImmediatePropagation()
606+ jQuery . extend ( saved [ 0 ] , jQuery . Event . prototype ) ,
607+ saved . slice ( 1 ) ,
608+ this
609+ )
610+ } ) ;
605611
606612 // Abort handling of the native event
607613 event . stopImmediatePropagation ( ) ;
0 commit comments