( el, type, expectSync )
| 5610 | // *native* events that it fires directly, ensuring that state changes have |
| 5611 | // already occurred before other listeners are invoked. |
| 5612 | function leverageNative( el, type, expectSync ) { |
| 5613 | |
| 5614 | // Missing expectSync indicates a trigger call, which must force setup through jQuery.event.add |
| 5615 | if ( !expectSync ) { |
| 5616 | if ( dataPriv.get( el, type ) === undefined ) { |
| 5617 | jQuery.event.add( el, type, returnTrue ); |
| 5618 | } |
| 5619 | return; |
| 5620 | } |
| 5621 | |
| 5622 | // Register the controller as a special universal handler for all event namespaces |
| 5623 | dataPriv.set( el, type, false ); |
| 5624 | jQuery.event.add( el, type, { |
| 5625 | namespace: false, |
| 5626 | handler: function( event ) { |
| 5627 | var notAsync, result, |
| 5628 | saved = dataPriv.get( this, type ); |
| 5629 | |
| 5630 | if ( ( event.isTrigger & 1 ) && this[ type ] ) { |
| 5631 | |
| 5632 | // Interrupt processing of the outer synthetic .trigger()ed event |
| 5633 | // Saved data should be false in such cases, but might be a leftover capture object |
| 5634 | // from an async native handler (gh-4350) |
| 5635 | if ( !saved.length ) { |
| 5636 | |
| 5637 | // Store arguments for use when handling the inner native event |
| 5638 | // There will always be at least one argument (an event object), so this array |
| 5639 | // will not be confused with a leftover capture object. |
| 5640 | saved = slice.call( arguments ); |
| 5641 | dataPriv.set( this, type, saved ); |
| 5642 | |
| 5643 | // Trigger the native event and capture its result |
| 5644 | // Support: IE <=9 - 11+ |
| 5645 | // focus() and blur() are asynchronous |
| 5646 | notAsync = expectSync( this, type ); |
| 5647 | this[ type ](); |
| 5648 | result = dataPriv.get( this, type ); |
| 5649 | if ( saved !== result || notAsync ) { |
| 5650 | dataPriv.set( this, type, false ); |
| 5651 | } else { |
| 5652 | result = {}; |
| 5653 | } |
| 5654 | if ( saved !== result ) { |
| 5655 | |
| 5656 | // Cancel the outer synthetic event |
| 5657 | event.stopImmediatePropagation(); |
| 5658 | event.preventDefault(); |
| 5659 | return result.value; |
| 5660 | } |
| 5661 | |
| 5662 | // If this is an inner synthetic event for an event with a bubbling surrogate |
| 5663 | // (focus or blur), assume that the surrogate already propagated from triggering the |
| 5664 | // native event and prevent that from happening again here. |
| 5665 | // This technically gets the ordering wrong w.r.t. to `.trigger()` (in which the |
| 5666 | // bubbling surrogate propagates *after* the non-bubbling base), but that seems |
| 5667 | // less bad than duplication. |
| 5668 | } else if ( ( jQuery.event.special[ type ] || {} ).delegateType ) { |
| 5669 | event.stopPropagation(); |
no test coverage detected