aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDave Methvin <dave.methvin@gmail.com>2011-04-12 19:29:09 -0400
committerDave Methvin <dave.methvin@gmail.com>2011-04-12 19:29:09 -0400
commitbebd8bc01e63dcb053412f8b247e4fa611867c55 (patch)
tree1908fde77bb03270e6d703bb67a35021d0969c58 /src
parent6d49e84dafd8990221913944727e4f5dcaec078d (diff)
downloadjquery-bebd8bc01e63dcb053412f8b247e4fa611867c55.tar.gz
jquery-bebd8bc01e63dcb053412f8b247e4fa611867c55.zip
Followup to #8753. Modify new Event constructor signature to jQuery.event(type, props), which can be exploited by jQuery.event.trigger as well.
Diffstat (limited to 'src')
-rw-r--r--src/event.js24
1 files changed, 9 insertions, 15 deletions
diff --git a/src/event.js b/src/event.js
index f005f7285..dd48e7f77 100644
--- a/src/event.js
+++ b/src/event.js
@@ -304,9 +304,9 @@ jQuery.event = {
// jQuery.Event object
event[ jQuery.expando ] ? event :
// Object literal
- jQuery.extend( new jQuery.Event(type), event ) :
+ new jQuery.Event( type, event ) :
// Just the event type (string)
- new jQuery.Event(type);
+ new jQuery.Event( type );
event.type = type;
event.namespace = namespaces.join(".");
@@ -563,26 +563,15 @@ jQuery.removeEvent = document.removeEventListener ?
}
};
-jQuery.Event = function( src ) {
+jQuery.Event = function( src, props ) {
// Allow instantiation without the 'new' keyword
if ( !this.preventDefault ) {
- return new jQuery.Event( src );
+ return new jQuery.Event( src, props );
}
// Event object
if ( src && src.type ) {
this.originalEvent = src;
-
- // 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 ];
- }
- }
-
- // Always ensure a type has been explicitly set
this.type = src.type;
// Events bubbling up the document may have been marked as prevented
@@ -595,6 +584,11 @@ jQuery.Event = function( src ) {
this.type = src;
}
+ // Put explicitly provided properties onto the event object
+ if ( props ) {
+ jQuery.extend( this, props );
+ }
+
// timeStamp is buggy for some events on Firefox(#3843)
// So we won't rely on the native value
this.timeStamp = jQuery.now();