]> source.dussan.org Git - jquery.git/commitdiff
Corrected RegExp to match event namespaces. Fixes #5303.
authorRobert Katic <robert.katic@gmail.com>
Thu, 19 Nov 2009 05:11:29 +0000 (13:11 +0800)
committerJohn Resig <jeresig@gmail.com>
Wed, 25 Nov 2009 16:58:39 +0000 (00:58 +0800)
src/event.js
test/unit/event.js

index 014fb7362e111ea6bef95b5ed5364b9ecdd19b55..879f049f10da3a38807f6034b14dfad04efb986c 100644 (file)
@@ -133,7 +133,7 @@ jQuery.event = {
                                        var namespaces = type.split(".");
                                        type = namespaces.shift();
                                        var all = !namespaces.length,
-                                               namespace = new RegExp("(^|\\.)" + namespaces.slice(0).sort().join(".*\\.") + "(\\.|$)"),
+                                               namespace = new RegExp("(^|\\.)" + namespaces.slice().sort().join("\\.(?:.*\\.)?") + "(\\.|$)"),
                                                special = this.special[ type ] || {};
 
                                        if ( events[ type ] ) {
@@ -291,7 +291,7 @@ jQuery.event = {
                // Cache this now, all = true means, any handler
                all = !namespaces.length && !event.exclusive;
 
-               var namespace = new RegExp("(^|\\.)" + namespaces.slice(0).sort().join(".*\\.") + "(\\.|$)");
+               var namespace = new RegExp("(^|\\.)" + namespaces.slice().sort().join("\\.(?:.*\\.)?") + "(\\.|$)");
 
                handlers = ( jQuery.data(this, "events") || {} )[ event.type ];
 
index 2b4d8e59c693bc091f9c3ce1286644eeca8f3938..74810086eee6181f6f5916a9c6f44684324feb79 100644 (file)
@@ -192,6 +192,10 @@ test("bind(), multi-namespaced events", function() {
        jQuery("#firstp").bind("click.test.abc",function(e){
                check("click.test.abc", "Namespaced click triggered");
        });
+       
+       // Those would not trigger/unbind (#5303)
+       jQuery("#firstp").trigger("click.a.test");
+       jQuery("#firstp").unbind("click.a.test");
 
        // Trigger both bound fn (1)
        jQuery("#firstp").trigger("click.test.abc");