Make sure that .die() with no args works. Fixes #5789.
[jquery.git] / test / unit / event.js
index 8a9e48b..99ed419 100644 (file)
@@ -608,7 +608,7 @@ test("toggle(Function, Function, ...)", function() {
 });
 
 test(".live()/.die()", function() {
-       expect(61);
+       expect(62);
 
        var submit = 0, div = 0, livea = 0, liveb = 0;
 
@@ -675,6 +675,13 @@ test(".live()/.die()", function() {
        equals( livea, 6, "stopPropagation Click on inner div" );
        equals( liveb, 3, "stopPropagation Click on inner div" );
 
+       // Make sure click events only fire with primary click
+       var event = jQuery.Event("click");
+       event.button = 1;
+       jQuery("div#nothiddendiv").trigger(event);
+
+       equals( livea, 6, "live secondary click" );
+
        jQuery("div#nothiddendivchild").die("click");
        jQuery("div#nothiddendiv").die("click");
        jQuery("div").die("click");
@@ -857,6 +864,35 @@ test(".live()/.die()", function() {
        jQuery("#nothiddendiv div").die("click");
 });
 
+test("die all bound events", function(){
+       expect(1);
+
+       var count = 0;
+       var div = jQuery("div#nothiddendivchild");
+
+       div.live("click submit", function(){ count++; });
+       div.die();
+
+       div.trigger("click");
+       div.trigger("submit");
+
+       equals( count, 0, "Make sure no events were triggered." );
+});
+
+test("live with multiple events", function(){
+       expect(1);
+
+       var count = 0;
+       var div = jQuery("div#nothiddendivchild");
+
+       div.live("click submit", function(){ count++; });
+
+       div.trigger("click");
+       div.trigger("submit");
+
+       equals( count, 2, "Make sure both the click and submit were triggered." );
+});
+
 test("live with change", function(){
        var selectChange = 0, checkboxChange = 0;