Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Style sweep #531

Merged
merged 2 commits into from over 2 years ago

3 participants

Rick Waldron Mike Sherov Dave Methvin
Rick Waldron
Collaborator

No description provided.

Mike Sherov

jquery(cur) should be jquery( cur )

Collaborator

Generally parens inside of parens are an exception. I've changed it to be consistent with is( sel )

Dave Methvin dmethvin merged commit cec0d0d into from
Dave Methvin dmethvin closed this
Oleg Gaidarenko markelog referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 2 unique commits by 1 author.

Oct 06, 2011
Rick Waldron Style sweep 4fd70e7
Rick Waldron Additional nits 3999d39
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 36 additions and 26 deletions. Show diff stats Hide diff stats

  1. 62  src/event.js
62  src/event.js
@@ -6,7 +6,7 @@ var rnamespaces = /\.(.*)$/,
6 6
 	rspaces = / /g,
7 7
 	rescape = /[^\w\s.|`]/g,
8 8
 	rtypenamespace = /^([^\.]*)?(?:\.(.+))?$/,
9  
-	rhoverHack =  /\bhover(\.\S+)?/,
  9
+	rhoverHack = /\bhover(\.\S+)?/,
10 10
 	rkeyEvent = /^key/,
11 11
 	rmouseEvent = /^(?:mouse|contextmenu)|click/,
12 12
 	rquickIs = /^([\w\-]+)?(?:#([\w\-]+))?(?:\.([\w\-]+))?(?:\[([\w+\-]+)=["']?([\w\-]*)["']?\])?$/,
@@ -88,16 +88,21 @@ jQuery.event = {
88 88
 		types = types.replace( rhoverHack, "mouseover$1 mouseout$1" ).split( " " );
89 89
 		for ( t = 0; t < types.length; t++ ) {
90 90
 
91  
-			tns = rtypenamespace.exec( types[t]  ) || [];
  91
+			tns = rtypenamespace.exec( types[t] ) || [];
92 92
 			type = tns[1];
93 93
 			namespaces = (tns[2] || "").split( "." ).sort();
94 94
 
95 95
 			// If event changes its type, use the special event handlers for the changed type
96 96
 			special = jQuery.event.special[ type ] || {};
97  
-			type = (selector? special.delegateType : special.bindType ) || type;
  97
+
  98
+			// If selector defined, determine special event api type, otherwise given type
  99
+			type = ( selector ? special.delegateType : special.bindType ) || type;
  100
+
  101
+			// Update special based on newly reset type
98 102
 			special = jQuery.event.special[ type ] || {};
99 103
 
100 104
 			// handleObj is passed to all event handlers
  105
+			// will be the result of merging handleObjIn
101 106
 			handleObj = jQuery.extend({
102 107
 				type: type,
103 108
 				origType: tns[1],
@@ -106,7 +111,7 @@ jQuery.event = {
106 111
 				guid: handler.guid,
107 112
 				selector: selector,
108 113
 				namespace: namespaces.join(".")
109  
-			}, handleObjIn);
  114
+			}, handleObjIn );
110 115
 
111 116
 			// Delegated event; pre-analyze selector so it's processed quickly on event dispatch
112 117
 			if ( selector ) {
@@ -185,7 +190,7 @@ jQuery.event = {
185 190
 			namespaces = tns[2];
186 191
 
187 192
 			// Unbind all events (on this namespace, if provided) for the element
188  
-			if ( !type  ) {
  193
+			if ( !type ) {
189 194
 				namespaces = namespaces? "." + namespaces : "";
190 195
 				for ( j in events ) {
191 196
 					jQuery.event.remove( elem, j + namespaces, handler, selector );
@@ -194,10 +199,10 @@ jQuery.event = {
194 199
 			}
195 200
 
196 201
 			special = jQuery.event.special[ type ] || {};
197  
-			type = (selector? special.delegateType : special.bindType ) || type;
  202
+			type = ( selector? special.delegateType : special.bindType ) || type;
198 203
 			eventType = events[ type ] || [];
199 204
 			origCount = eventType.length;
200  
-			namespaces =  namespaces? new RegExp("(^|\\.)" + namespaces.split(".").sort().join("\\.(?:.*\\.)?") + "(\\.|$)") : null;
  205
+			namespaces = namespaces ? new RegExp("(^|\\.)" + namespaces.split(".").sort().join("\\.(?:.*\\.)?") + "(\\.|$)") : null;
201 206
 
202 207
 			// Only need to loop for special events or selective removal
203 208
 			if ( handler || namespaces || selector || special.remove ) {
@@ -265,7 +270,7 @@ jQuery.event = {
265 270
 		// Event object or event type
266 271
 		var type = event.type || event,
267 272
 			namespaces = [],
268  
-			exclusive, i, cur, old, ontype, special, doc, eventPath, bubbleType,
  273
+			cache, exclusive, i, cur, old, ontype, special, doc, eventPath, bubbleType,
269 274
 			addHandlers = function( elem, type ) {
270 275
 				// Defer getting handler so we don't waste time in case propagation is stopped
271 276
 				if ( (jQuery._data( elem, "events" ) || {})[ type ] ) {
@@ -321,7 +326,7 @@ jQuery.event = {
321 326
 		if ( !elem ) {
322 327
 
323 328
 			// TODO: Stop taunting the data cache; remove global events and always attach to document
324  
-			var cache = jQuery.cache;
  329
+			cache = jQuery.cache;
325 330
 			for ( i in cache ) {
326 331
 				if ( cache[ i ].events && cache[ i ].events[ type ] ) {
327 332
 					jQuery.event.trigger( event, data, cache[ i ].handle.elem );
@@ -364,7 +369,7 @@ jQuery.event = {
364 369
 		for ( i = 0; i < eventPath.length; i++ ) {
365 370
 			cur = eventPath[ i ];
366 371
 			event.type = cur.type;
367  
-			(cur.handler ||  jQuery._data( cur.elem, "handle" )).apply( cur.elem, data );
  372
+			( cur.handler || jQuery._data( cur.elem, "handle" ) ).apply( cur.elem, data );
368 373
 			if ( event.isPropagationStopped() ) {
369 374
 				break;
370 375
 			}
@@ -382,6 +387,7 @@ jQuery.event = {
382 387
 				// Don't do default actions on window, that's where global variables be (#6170)
383 388
 				// IE<9 dies on focus/blur to hidden element (#1486)
384 389
 				if ( ontype && elem[ type ] && ((type !== "focus" && type !== "blur") || event.target.offsetWidth !== 0) && !jQuery.isWindow( elem ) ) {
  390
+
385 391
 					// Don't re-trigger an onFOO event when we call its FOO() method
386 392
 					old = elem[ ontype ];
387 393
 
@@ -411,7 +417,7 @@ jQuery.event = {
411 417
 
412 418
 		var handlers = ((jQuery._data( this, "events" ) || {})[ event.type ] || []),
413 419
 			delegateCount = handlers.delegateCount,
414  
-			args = Array.prototype.slice.call( arguments, 0 ),
  420
+			args = [].slice.call( arguments, 0 ),
415 421
 			handlerQueue = [],
416 422
 			i, cur, selMatch, matches, handleObj, sel, hit, related;
417 423
 
@@ -432,9 +438,9 @@ jQuery.event = {
432 438
 
433 439
 					if ( handleObj.isPositional ) {
434 440
 						// Since .is() does not work for positionals; see http://jsfiddle.net/eJ4yd/3/
435  
-						hit = (hit || (selMatch[ sel ] = jQuery( sel ))).index( cur ) >= 0;
  441
+						hit = ( hit || (selMatch[ sel ] = jQuery( sel )) ).index( cur ) >= 0;
436 442
 					} else if ( hit === undefined ) {
437  
-						hit = selMatch[ sel ] = (handleObj.quick? quickIs( cur, handleObj.quick ) : jQuery( cur ).is( sel ));
  443
+						hit = selMatch[ sel ] = ( handleObj.quick ? quickIs( cur, handleObj.quick ) : jQuery( cur ).is( sel ) );
438 444
 					}
439 445
 					if ( hit ) {
440 446
 						matches.push( handleObj );
@@ -509,7 +515,7 @@ jQuery.event = {
509 515
 			// Add which for click: 1 === left; 2 === middle; 3 === right
510 516
 			// Note: button is not normalized, so don't use it
511 517
 			if ( !event.which && button !== undefined ) {
512  
-				event.which = (button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ));
  518
+				event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) );
513 519
 			}
514 520
 
515 521
 			return event;
@@ -524,11 +530,12 @@ jQuery.event = {
524 530
 		// Create a writable copy of the event object and normalize some properties
525 531
 		var originalEvent = event,
526 532
 			fixHook = jQuery.event.fixHooks[ event.type ] || {},
527  
-			copy =  fixHook.props ? this.props.concat( fixHook.props ) : this.props;
  533
+			copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props,
  534
+			i;
528 535
 
529 536
 		event = jQuery.Event( originalEvent );
530 537
 
531  
-		for ( var i = copy.length, prop; i; ) {
  538
+		for ( i = copy.length, prop; i; ) {
532 539
 			prop = copy[ --i ];
533 540
 			event[ prop ] = originalEvent[ prop ];
534 541
 		}
@@ -592,10 +599,13 @@ jQuery.event = {
592 599
 		// Piggyback on a donor event to simulate a different one.
593 600
 		// Fake originalEvent to avoid donor's stopPropagation, but if the
594 601
 		// simulated event prevents default then we do the same on the donor.
595  
-		var e = jQuery.extend( 
596  
-			new jQuery.Event(), 
597  
-			event, 
598  
-			{ type: type, isSimulated: true, originalEvent: {} }
  602
+		var e = jQuery.extend(
  603
+			new jQuery.Event(),
  604
+			event,
  605
+			{ type: type,
  606
+				isSimulated: true,
  607
+				originalEvent: {}
  608
+			}
599 609
 		);
600 610
 		if ( bubble ) {
601 611
 			jQuery.event.trigger( e, null, elem );
@@ -611,7 +621,7 @@ jQuery.event = {
611 621
 // Run jQuery handler functions; called from jQuery.event.handle
612 622
 function dispatch( target, event, handlers, args ) {
613 623
 	var run_all = !event.exclusive && !event.namespace,
614  
-		specialHandle = (jQuery.event.special[event.type] || {}).handle,
  624
+		specialHandle = ( jQuery.event.special[ event.type ] || {} ).handle,
615 625
 		j, handleObj, ret;
616 626
 
617 627
 	event.currentTarget = target;
@@ -628,7 +638,7 @@ function dispatch( target, event, handlers, args ) {
628 638
 			event.data = handleObj.data;
629 639
 			event.handleObj = handleObj;
630 640
 
631  
-			ret = (specialHandle || handleObj.handler).apply( target, args );
  641
+			ret = ( specialHandle || handleObj.handler ).apply( target, args );
632 642
 
633 643
 			if ( ret !== undefined ) {
634 644
 				event.result = ret;
@@ -666,8 +676,8 @@ jQuery.Event = function( src, props ) {
666 676
 
667 677
 		// Events bubbling up the document may have been marked as prevented
668 678
 		// by a handler lower down the tree; reflect the correct value.
669  
-		this.isDefaultPrevented = (src.defaultPrevented || src.returnValue === false ||
670  
-			src.getPreventDefault && src.getPreventDefault()) ? returnTrue : returnFalse;
  679
+		this.isDefaultPrevented = ( src.defaultPrevented || src.returnValue === false ||
  680
+			src.getPreventDefault && src.getPreventDefault() ) ? returnTrue : returnFalse;
671 681
 
672 682
 	// Event type
673 683
 	} else {
@@ -836,7 +846,7 @@ if ( !jQuery.support.changeBubbles ) {
836 846
 			jQuery.event.add( this, "beforeactivate._change", function( e ) {
837 847
 				var elem = e.target;
838 848
 
839  
-				if ( rformElems.test( elem.nodeName ) && !elem._change_attached ) {					
  849
+				if ( rformElems.test( elem.nodeName ) && !elem._change_attached ) {
840 850
 					jQuery.event.add( elem, "change._change", function( event ) {
841 851
 						if ( this.parentNode && !event.isSimulated ) {
842 852
 							jQuery.event.simulate( "change", this.parentNode, event, true );
@@ -846,7 +856,7 @@ if ( !jQuery.support.changeBubbles ) {
846 856
 				}
847 857
 			});
848 858
 		},
849  
-		
  859
+
850 860
 		handle: function( event ) {
851 861
 			var elem = event.target;
852 862
 
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.