From 3fce79484434298fb6ad16030674c14b9600b22e Mon Sep 17 00:00:00 2001 From: Dave Methvin Date: Sat, 24 Nov 2012 16:03:57 -0500 Subject: [PATCH] Fix #12733. Ignore excess spaciness in event strings. Thanks @bentruyman! --- src/event.js | 5 +++-- test/unit/event.js | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/event.js b/src/event.js index e92336a91..a40bc0859 100644 --- a/src/event.js +++ b/src/event.js @@ -1,5 +1,6 @@ var rformElems = /^(?:textarea|input|select)$/i, rtypenamespace = /^([^\.]*|)(?:\.(.+)|)$/, + reventTypes = /\S+/g, rkeyEvent = /^key/, rmouseEvent = /^(?:mouse|contextmenu)|click/, rfocusMorph = /^(?:focusinfocus|focusoutblur)$/; @@ -52,7 +53,7 @@ jQuery.event = { // Handle multiple events separated by a space // jQuery(...).bind("mouseover mouseout", fn); - types = jQuery.trim( types ).split( " " ); + types = (types || "").match( reventTypes ) || [""]; for ( t = 0; t < types.length; t++ ) { tns = rtypenamespace.exec( types[t] ) || []; @@ -135,7 +136,7 @@ jQuery.event = { } // Once for each type.namespace in types; type may be omitted - types = jQuery.trim( types ).split(" "); + types = (types || "").match( reventTypes ) || [""]; for ( t = 0; t < types.length; t++ ) { tns = rtypenamespace.exec( types[t] ) || []; type = origType = tns[1]; diff --git a/test/unit/event.js b/test/unit/event.js index d4224d78f..78f7fe9af 100644 --- a/test/unit/event.js +++ b/test/unit/event.js @@ -2650,7 +2650,7 @@ test(".on and .off", function() { counter += (e.data || 0) + (trig || 1); }; jQuery( "#onandoff" ) - .on( "click clack cluck", "em", 2, mixfn ) + .on( " click clack cluck ", "em", 2, mixfn ) .on( "cluck", "b", 7, mixfn ) .on( "cluck", mixfn ) .trigger( "what!" ) -- 2.39.5