Fixed #2027 - make sure that cloned elements (within appendTo, etc.) have their event...
[jquery.git] / test / unit / event.js
index 6104481..43a4542 100644 (file)
@@ -1,7 +1,7 @@
 module("event");
 
 test("bind()", function() {
-       expect(18);
+       expect(19);
 
        var handler = function(event) {
                ok( event.data, "bind() with data, check passed data exists" );
@@ -85,6 +85,11 @@ test("bind()", function() {
        $("#nonnodes").contents().bind("tester", function () {
                equals(this.nodeType, 1, "Check node,textnode,comment bind just does real nodes" );
        }).trigger("tester");
+
+       // Make sure events stick with appendTo'd elements (which are cloned) #2027
+       $("<a href='#fail' class='test'>test</a>").click(function(){ return false; }).appendTo("p");
+       ok( $("a.test:first").triggerHandler("click") === false, "Handler is bound to appendTo'd elements" );
+       reset();
 });
 
 test("click()", function() {
@@ -217,6 +222,7 @@ test("trigger(event, [data], [fn])", function() {
 
        // Trigger only the handlers (no native) and extra fn, with external event obj
        // Triggers 9
+       eventObj = jQuery.event.fix({ type: "foo", target: document.body });
        equals( $("#firstp").triggerHandler("click", [eventObj, 1, "2", "abc"], handler), "test", "Verify handler response" );
        
        var pass = true;
@@ -270,4 +276,4 @@ test("jQuery(function($) {})", function() {
                equals(jQuery, $, "ready doesn't provide an event object, instead it provides a reference to the jQuery function, see http://docs.jquery.com/Events/ready#fn");
                start();
        });
-});
\ No newline at end of file
+});