Skip to content

Commit

Permalink
Event: Fix handling of multiple async focus events
Browse files Browse the repository at this point in the history
  • Loading branch information
gibson042 committed Apr 15, 2019
1 parent 71aa120 commit 2600b30
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/event.js
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,9 @@ function leverageNative( el, type, expectSync ) {
if ( ( event.isTrigger & 1 ) && this[ type ] ) {

// Interrupt processing of the outer synthetic .trigger()ed event
if ( !saved ) {
// Saved data should be false in such cases, but might be a leftover capture object
// from an async native handler (gh-4350)
if ( !( saved.length >= 0 ) ) {

// Store arguments for use when handling the inner native event
saved = slice.call( arguments );
Expand All @@ -569,14 +571,14 @@ function leverageNative( el, type, expectSync ) {
if ( saved !== result || notAsync ) {
dataPriv.set( this, type, false );
} else {
result = undefined;
result = {};
}
if ( saved !== result ) {

// Cancel the outer synthetic event
event.stopImmediatePropagation();
event.preventDefault();
return result;
return result.value;
}

// If this is an inner synthetic event for an event with a bubbling surrogate
Expand All @@ -591,17 +593,17 @@ function leverageNative( el, type, expectSync ) {

// If this is a native event triggered above, everything is now in order
// Fire an inner synthetic event with the original arguments
} else if ( saved ) {
} else if ( saved.length >= 0 ) {

// ...and capture the result
dataPriv.set( this, type, jQuery.event.trigger(
dataPriv.set( this, type, { value: jQuery.event.trigger(

// Support: IE <=9 - 11+
// Extend with the prototype to reset the above stopImmediatePropagation()
jQuery.extend( saved.shift(), jQuery.Event.prototype ),
saved,
this
) );
) } );

// Abort handling of the native event
event.stopImmediatePropagation();
Expand Down

0 comments on commit 2600b30

Please sign in to comment.