]> source.dussan.org Git - jquery.git/commitdiff
Fix #12733. Ignore excess spaciness in event strings.
authorDave Methvin <dave.methvin@gmail.com>
Sat, 24 Nov 2012 21:03:57 +0000 (16:03 -0500)
committerDave Methvin <dave.methvin@gmail.com>
Sat, 24 Nov 2012 21:05:20 +0000 (16:05 -0500)
Thanks @bentruyman!

src/event.js
test/unit/event.js

index e92336a917bcf21b1f7946019b7eb10d6c666c57..a40bc08598bb231b1a821323d526b89ba833aecf 100644 (file)
@@ -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];
index d4224d78fa2bb7f4ab07c6dd4f88639ba7c23359..78f7fe9afcbaf6e3bdcf7a9fb17e1a38358e3e6a 100644 (file)
@@ -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!" )