Skip to main content

Bug Tracker

Side navigation

Ticket #3820: 3820.unit.patch


File 3820.unit.patch, 1.0 KB (added by iraebrasil, January 10, 2009 06:56PM UTC)

Unit test proposal for this issue that the patch passes and without the path, don't

Index: test/unit/event.js
===================================================================
--- test/unit/event.js	(revision 6078)
+++ test/unit/event.js	(working copy)
@@ -474,7 +474,7 @@
 });
 
 test(".live()/.die()", function() {
-	expect(36);
+	expect(38);
 
 	var submit = 0, div = 0, livea = 0, liveb = 0;
 
@@ -588,6 +588,19 @@
 
 	// Cleanup
 	jQuery("#nothiddendiv").die("foo", callback);
+	
+	// Make sure we don't loose the target by DOM modifications
+	// after the bubble already reached the liveHandler
+	var livec = 0,
+		elemDiv = jQuery("#nothiddendivchild").html('').get(0);
+	
+	jQuery("#nothiddendivchild").live("click", function(e){ jQuery("#nothiddendivchild").html(''); });
+	jQuery("#nothiddendivchild").live("click", function(e){ if(e.target) {livec++;} });
+	
+	jQuery("#nothiddendiv span").click();
+	equals( jQuery("#nothiddendiv span").size(), 0, "Verify that first handler occurred and modified the DOM." );
+	equals( livec, 1, "Verify that second handler occurred even with nuked target." );
+	
 });
 
 /*

Download in other formats:

Original Format