mirror of
https://github.com/jquery/jquery.git
synced 2026-02-11 01:05:14 -05:00
Ticket #8753 Allow special properties to explicitly defined on jQuery.Event objects
This commit is contained in:
17
src/event.js
17
src/event.js
@@ -1,6 +1,7 @@
|
||||
(function( jQuery ) {
|
||||
|
||||
var rnamespaces = /\.(.*)$/,
|
||||
var hasOwn = Object.prototype.hasOwnProperty,
|
||||
rnamespaces = /\.(.*)$/,
|
||||
rformElems = /^(?:textarea|input|select)$/i,
|
||||
rperiod = /\./g,
|
||||
rspace = / /g,
|
||||
@@ -581,6 +582,15 @@ jQuery.Event = function( src ) {
|
||||
this.originalEvent = src;
|
||||
this.type = src.type;
|
||||
|
||||
// Push explicitly provided properties onto the event object
|
||||
for ( var prop in src ) {
|
||||
// Ensure we don't clobber jQuery.Event prototype
|
||||
// with own properties.
|
||||
if ( hasOwn.call( src, prop ) ) {
|
||||
this[ prop ] = src[ prop ];
|
||||
}
|
||||
}
|
||||
|
||||
// Events bubbling up the document may have been marked as prevented
|
||||
// by a handler lower down the tree; reflect the correct value.
|
||||
this.isDefaultPrevented = (src.defaultPrevented || src.returnValue === false ||
|
||||
@@ -868,10 +878,10 @@ function trigger( type, elem, args ) {
|
||||
// Create "bubbling" focus and blur events
|
||||
if ( document.addEventListener ) {
|
||||
jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
|
||||
|
||||
|
||||
// Attach a single capturing handler while someone wants focusin/focusout
|
||||
var attaches = 0;
|
||||
|
||||
|
||||
jQuery.event.special[ fix ] = {
|
||||
setup: function() {
|
||||
if ( attaches++ === 0 ) {
|
||||
@@ -1184,3 +1194,4 @@ jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblcl
|
||||
});
|
||||
|
||||
})( jQuery );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user