fix regression in removing live events caused by r6324
[jquery.git] / src / event.js
index 1aafcfa..cac56bd 100644 (file)
@@ -190,9 +190,10 @@ jQuery.event = {
        },
 
        // bubbling is internal
-       trigger: function( event, data, elem, bubbling ) {
+       trigger: function( event, data, elem /*, bubbling */ ) {
                // Event object or event type
-               var type = event.type || event;
+               var type = event.type || event,
+                       bubbling = arguments[3];
 
                if ( !bubbling ) {
                        event = typeof event === "object" ?
@@ -401,8 +402,20 @@ jQuery.event = {
                                jQuery.event.add( this, data.live, liveHandler );
                        },
 
-                       teardown: function( namespaces ) {
-                               jQuery.event.remove( this, namespaces[0], liveHandler );
+                       remove: function( namespaces ) {
+                               if ( namespaces.length ) {
+                                       var remove = 0, name = new RegExp("(^|\\.)" + namespaces[0] + "(\\.|$)");
+
+                                       jQuery.each( (jQuery.data(this, "events").live || {}), function() {
+                                               if ( name.test(this.type) ) {
+                                                       remove++;
+                                               }
+                                       });
+
+                                       if ( remove < 1 ) {
+                                               jQuery.event.remove( this, namespaces[0], liveHandler );
+                                       }
+                               }
                        }
                }
        }
@@ -524,7 +537,7 @@ jQuery.fn.extend({
                }
                fn = thisObject === undefined ? fn : jQuery.event.proxy( fn, thisObject );
                return type === "unload" ? this.one(type, data, fn, thisObject) : this.each(function() {
-                       jQuery.event.add( this, type, fn, data, thisObject );
+                       jQuery.event.add( this, type, fn, data );
                });
        },
 
@@ -542,7 +555,7 @@ jQuery.fn.extend({
                        return fn.apply( this, arguments );
                });
                return this.each(function() {
-                       jQuery.event.add( this, type, one, data, thisObject );
+                       jQuery.event.add( this, type, one, data );
                });
        },