aboutsummaryrefslogtreecommitdiffstats
path: root/src/event.js
diff options
context:
space:
mode:
authorrwldrn <waldron.rick@gmail.com>2011-04-05 15:55:40 -0400
committerrwldrn <waldron.rick@gmail.com>2011-04-05 15:55:40 -0400
commit23a411b6bcbb96edbbfe53e11ec1671dccaa92b6 (patch)
tree10d3faf7fcfd8c0dfa20aa1941c1ee0ee03a401e /src/event.js
parent2ed81b44be958b5f2b5569ab15f22bde262b4eb6 (diff)
downloadjquery-23a411b6bcbb96edbbfe53e11ec1671dccaa92b6.tar.gz
jquery-23a411b6bcbb96edbbfe53e11ec1671dccaa92b6.zip
Ticket #8753 Allow special properties to explicitly defined on jQuery.Event objects
Diffstat (limited to 'src/event.js')
-rw-r--r--src/event.js17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/event.js b/src/event.js
index bc2cf76eb..eadfa05c1 100644
--- a/src/event.js
+++ b/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 );
+