11import jQuery from "./core.js" ;
2- import document from "./var/document.js" ;
32import documentElement from "./var/documentElement.js" ;
43import rnothtmlwhite from "./var/rnothtmlwhite.js" ;
54import rcheckableType from "./var/rcheckableType.js" ;
@@ -22,16 +21,6 @@ function returnFalse() {
2221 return false ;
2322}
2423
25- // Support: IE <=9 - 11+
26- // focus() and blur() are asynchronous, except when they are no-op.
27- // So expect focus to be synchronous when the element is already active,
28- // and blur to be synchronous when the element is not already active.
29- // (focus and blur are always synchronous in other supported browsers,
30- // this just defines when we can count on it).
31- function expectSync ( elem , type ) {
32- return ( elem === document . activeElement ) === ( type === "focus" ) ;
33- }
34-
3524function on ( elem , types , selector , data , fn , one ) {
3625 var origFn , type ;
3726
@@ -460,7 +449,7 @@ jQuery.event = {
460449 el . click && nodeName ( el , "input" ) ) {
461450
462451 // dataPriv.set( el, "click", ... )
463- leverageNative ( el , "click" , returnTrue ) ;
452+ leverageNative ( el , "click" , true ) ;
464453 }
465454
466455 // Return false to allow normal processing in the caller
@@ -512,10 +501,10 @@ jQuery.event = {
512501// synthetic events by interrupting progress until reinvoked in response to
513502// *native* events that it fires directly, ensuring that state changes have
514503// already occurred before other listeners are invoked.
515- function leverageNative ( el , type , expectSync ) {
504+ function leverageNative ( el , type , isSetup ) {
516505
517- // Missing expectSync indicates a trigger call, which must force setup through jQuery.event.add
518- if ( ! expectSync ) {
506+ // Missing `isSetup` indicates a trigger call, which must force setup through jQuery.event.add
507+ if ( ! isSetup ) {
519508 if ( dataPriv . get ( el , type ) === undefined ) {
520509 jQuery . event . add ( el , type , returnTrue ) ;
521510 }
@@ -527,15 +516,13 @@ function leverageNative( el, type, expectSync ) {
527516 jQuery . event . add ( el , type , {
528517 namespace : false ,
529518 handler : function ( event ) {
530- var notAsync , result ,
519+ var result ,
531520 saved = dataPriv . get ( this , type ) ;
532521
533522 if ( ( event . isTrigger & 1 ) && this [ type ] ) {
534523
535524 // Interrupt processing of the outer synthetic .trigger()ed event
536- // Saved data should be false in such cases, but might be a leftover capture object
537- // from an async native handler (gh-4350)
538- if ( ! saved . length ) {
525+ if ( ! saved ) {
539526
540527 // Store arguments for use when handling the inner native event
541528 // There will always be at least one argument (an event object), so this array
@@ -544,16 +531,10 @@ function leverageNative( el, type, expectSync ) {
544531 dataPriv . set ( this , type , saved ) ;
545532
546533 // Trigger the native event and capture its result
547- // Support: IE <=9 - 11+
548- // focus() and blur() are asynchronous
549- notAsync = expectSync ( this , type ) ;
550534 this [ type ] ( ) ;
551535 result = dataPriv . get ( this , type ) ;
552- if ( saved !== result || notAsync ) {
553- dataPriv . set ( this , type , false ) ;
554- } else {
555- result = { } ;
556- }
536+ dataPriv . set ( this , type , false ) ;
537+
557538 if ( saved !== result ) {
558539
559540 // Cancel the outer synthetic event
@@ -756,7 +737,7 @@ jQuery.each( { focus: "focusin", blur: "focusout" }, function( type, delegateTyp
756737 // Claim the first handler
757738 // dataPriv.set( this, "focus", ... )
758739 // dataPriv.set( this, "blur", ... )
759- leverageNative ( this , type , expectSync ) ;
740+ leverageNative ( this , type , true ) ;
760741
761742 if ( isIE ) {
762743 this . addEventListener ( delegateType , focusMappedHandler ) ;
0 commit comments