mirror of
https://github.com/jquery/jquery.git
synced 2026-02-01 22:14:58 -05:00
Event: remove outdated originalEvent hack
Closes gh-2335
Ref 7475d5debe
This commit is contained in:
20
src/event.js
20
src/event.js
@@ -601,23 +601,29 @@ jQuery.event = {
|
||||
}
|
||||
},
|
||||
|
||||
// Piggyback on a donor event to simulate a different one
|
||||
simulate: function( type, elem, event, bubble ) {
|
||||
// Piggyback on a donor event to simulate a different one.
|
||||
// Fake originalEvent to avoid donor's stopPropagation, but if the
|
||||
// simulated event prevents default then we do the same on the donor.
|
||||
var e = jQuery.extend(
|
||||
new jQuery.Event(),
|
||||
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
|
||||
}
|
||||
);
|
||||
|
||||
// This prevents stopPropagation(), stopImmediatePropagation(), and preventDefault() from
|
||||
// preventing default on the donor event.
|
||||
delete e.originalEvent;
|
||||
|
||||
if ( bubble ) {
|
||||
jQuery.event.trigger( e, null, elem );
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user