Make sure that the teardown is called after all the handlers of a type are removed...
[jquery.git] / src / event.js
index 2e510ea..e15a2ea 100644 (file)
@@ -221,7 +221,7 @@ jQuery.event = {
                        }
 
                        // remove generic event handler if no more handlers exist
-                       if ( jQuery.isEmptyObject( events[ type ] ) ) {
+                       if ( eventType.length === 0 || pos != null && eventType.length === 1 ) {
                                if ( !special.teardown || special.teardown.call( elem, namespaces ) === false ) {
                                        removeEvent( elem, type, elemData.handle );
                                }