Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fix #12733. Ignore excess spaciness in event strings.

Thanks @bentruyman!
  • Loading branch information...
commit 3fce79484434298fb6ad16030674c14b9600b22e 1 parent 6b00b3c
Dave Methvin authored
5  src/event.js
... ...
@@ -1,5 +1,6 @@
1 1
 var rformElems = /^(?:textarea|input|select)$/i,
2 2
 	rtypenamespace = /^([^\.]*|)(?:\.(.+)|)$/,
  3
+	reventTypes = /\S+/g,
3 4
 	rkeyEvent = /^key/,
4 5
 	rmouseEvent = /^(?:mouse|contextmenu)|click/,
5 6
 	rfocusMorph = /^(?:focusinfocus|focusoutblur)$/;
@@ -52,7 +53,7 @@ jQuery.event = {
52 53
 
53 54
 		// Handle multiple events separated by a space
54 55
 		// jQuery(...).bind("mouseover mouseout", fn);
55  
-		types = jQuery.trim( types ).split( " " );
  56
+		types = (types || "").match( reventTypes ) || [""];
56 57
 		for ( t = 0; t < types.length; t++ ) {
57 58
 
58 59
 			tns = rtypenamespace.exec( types[t] ) || [];
@@ -135,7 +136,7 @@ jQuery.event = {
135 136
 		}
136 137
 
137 138
 		// Once for each type.namespace in types; type may be omitted
138  
-		types = jQuery.trim( types ).split(" ");
  139
+		types = (types || "").match( reventTypes ) || [""];
139 140
 		for ( t = 0; t < types.length; t++ ) {
140 141
 			tns = rtypenamespace.exec( types[t] ) || [];
141 142
 			type = origType = tns[1];
2  test/unit/event.js
@@ -2650,7 +2650,7 @@ test(".on and .off", function() {
2650 2650
 		counter += (e.data || 0) + (trig || 1);
2651 2651
 	};
2652 2652
 	jQuery( "#onandoff" )
2653  
-		.on( "click clack cluck", "em", 2, mixfn )
  2653
+		.on( " click  clack cluck ", "em", 2, mixfn )
2654 2654
 		.on( "cluck", "b", 7, mixfn )
2655 2655
 		.on( "cluck", mixfn )
2656 2656
 		.trigger( "what!" )

0 notes on commit 3fce794

Please sign in to comment.
Something went wrong with that request. Please try again.