aboutsummaryrefslogtreecommitdiffstats
path: root/test/unit
diff options
context:
space:
mode:
authorDave Methvin <dave.methvin@gmail.com>2011-10-23 22:25:13 -0400
committerDave Methvin <dave.methvin@gmail.com>2011-10-24 11:18:18 -0400
commit4ac6f8d9d322c7e468ed0d58e402abe7bdca354d (patch)
tree6c93204fd084fdb68b52a14bc9b876c8e6b1796c /test/unit
parentb208042f520b2ee768a93323d6bdc65eabfb0d65 (diff)
downloadjquery-4ac6f8d9d322c7e468ed0d58e402abe7bdca354d.tar.gz
jquery-4ac6f8d9d322c7e468ed0d58e402abe7bdca354d.zip
Make jQuery().off(event) work for delegated events.
Logic to handle detaching by event was in both .off() and jQuery.event.remove; now it's only in .off(). It's a bit of a strange case since the event object (not the jQuery set) specifies the element.
Diffstat (limited to 'test/unit')
-rw-r--r--test/unit/event.js14
1 files changed, 14 insertions, 0 deletions
diff --git a/test/unit/event.js b/test/unit/event.js
index 905e6ab99..bb622f577 100644
--- a/test/unit/event.js
+++ b/test/unit/event.js
@@ -2054,6 +2054,20 @@ test(".delegate()/.undelegate()", function() {
jQuery("#body").undelegate("#nothiddendiv div", "click");
});
+test("jQuery.off using dispatched jQuery.Event", function() {
+ expect(1);
+
+ var markup = jQuery( '<p><a href="#">target</a></p>' ),
+ count = 0;
+ markup
+ .on( "click.name", "a", function( event ) {
+ equals( ++count, 1, "event called once before removal" );
+ jQuery().off( event );
+ })
+ .find( "a" ).click().click().end()
+ .remove();
+});
+
test("stopPropagation() stops directly-bound events on delegated target", function() {
expect(1);