mirror of
https://github.com/jquery/jquery.git
synced 2026-04-20 03:01:22 -04:00
Events: don't execute native stop(Immediate)Propagation from simulation
In Firefox, called `stop(Immediate)Propagation` methods, in capturing phase prevents receiving focus Fixes gh-3111
This commit is contained in:
@@ -558,13 +558,14 @@ jQuery.Event.prototype = {
|
||||
isDefaultPrevented: returnFalse,
|
||||
isPropagationStopped: returnFalse,
|
||||
isImmediatePropagationStopped: returnFalse,
|
||||
isSimulated: false,
|
||||
|
||||
preventDefault: function() {
|
||||
var e = this.originalEvent;
|
||||
|
||||
this.isDefaultPrevented = returnTrue;
|
||||
|
||||
if ( e ) {
|
||||
if ( e && !this.isSimulated ) {
|
||||
e.preventDefault();
|
||||
}
|
||||
},
|
||||
@@ -573,7 +574,7 @@ jQuery.Event.prototype = {
|
||||
|
||||
this.isPropagationStopped = returnTrue;
|
||||
|
||||
if ( e ) {
|
||||
if ( e && !this.isSimulated ) {
|
||||
e.stopPropagation();
|
||||
}
|
||||
},
|
||||
@@ -582,7 +583,7 @@ jQuery.Event.prototype = {
|
||||
|
||||
this.isImmediatePropagationStopped = returnTrue;
|
||||
|
||||
if ( e ) {
|
||||
if ( e && !this.isSimulated ) {
|
||||
e.stopImmediatePropagation();
|
||||
}
|
||||
|
||||
|
||||
@@ -150,6 +150,7 @@ jQuery.extend( jQuery.event, {
|
||||
},
|
||||
|
||||
// Piggyback on a donor event to simulate a different one
|
||||
// Used only for `focus(in | out)` events
|
||||
simulate: function( type, elem, event ) {
|
||||
var e = jQuery.extend(
|
||||
new jQuery.Event(),
|
||||
@@ -157,27 +158,10 @@ jQuery.extend( jQuery.event, {
|
||||
{
|
||||
type: type,
|
||||
isSimulated: true
|
||||
|
||||
// Previously, `originalEvent: {}` was set here, so stopPropagation call
|
||||
// would not be triggered on donor event, since in our own
|
||||
// jQuery.event.stopPropagation function we had a check for existence of
|
||||
// originalEvent.stopPropagation method, so, consequently it would be a noop.
|
||||
//
|
||||
// But now, this "simulate" function is used only for events
|
||||
// for which stopPropagation() is noop, so there is no need for that anymore.
|
||||
//
|
||||
// For the compat branch though, guard for "click" and "submit"
|
||||
// events is still used, but was moved to jQuery.event.stopPropagation function
|
||||
// because `originalEvent` should point to the original event for the constancy
|
||||
// with other events and for more focused logic
|
||||
}
|
||||
);
|
||||
|
||||
jQuery.event.trigger( e, null, elem );
|
||||
|
||||
if ( e.isDefaultPrevented() ) {
|
||||
event.preventDefault();
|
||||
}
|
||||
}
|
||||
|
||||
} );
|
||||
|
||||
Reference in New Issue
Block a user