aboutsummaryrefslogtreecommitdiffstats
path: root/src/event.js
diff options
context:
space:
mode:
authorDamian Senn <jquery@topaxi.codes>2016-01-14 21:24:43 +0100
committerDave Methvin <dave.methvin@gmail.com>2016-04-27 09:13:16 -0400
commit9f268caaf43629addb9a1a2001ab341839300b14 (patch)
tree876af987ce463cf93dd7f95570f15db074bd63d5 /src/event.js
parentdf2051cf59d054d7ee91bdb554b583471942c6b4 (diff)
downloadjquery-9f268caaf43629addb9a1a2001ab341839300b14.tar.gz
jquery-9f268caaf43629addb9a1a2001ab341839300b14.zip
Event: Make event dispatch optimizable by JavaScript engines
Closes gh-2834 - Do not assign to function parameters - Do not pass arguments object to other functions
Diffstat (limited to 'src/event.js')
-rw-r--r--src/event.js14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/event.js b/src/event.js
index e382de6d2..4015f8768 100644
--- a/src/event.js
+++ b/src/event.js
@@ -283,19 +283,23 @@ jQuery.event = {
}
},
- dispatch: function( event ) {
+ dispatch: function( nativeEvent ) {
// Make a writable jQuery.Event from the native event object
- event = jQuery.event.fix( event );
+ var event = jQuery.event.fix( nativeEvent );
- var i, j, ret, matched, handleObj,
- handlerQueue = [],
- args = slice.call( arguments ),
+ var i, j, ret, matched, handleObj, handlerQueue,
+ args = new Array( arguments.length ),
handlers = ( dataPriv.get( this, "events" ) || {} )[ event.type ] || [],
special = jQuery.event.special[ event.type ] || {};
// Use the fix-ed jQuery.Event rather than the (read-only) native event
args[ 0 ] = event;
+
+ for ( i = 1; i < arguments.length; i++ ) {
+ args[ i ] = arguments[ i ];
+ }
+
event.delegateTarget = this;
// Call the preDispatch hook for the mapped type, and let it bail if desired