diff options
author | Dave Methvin <dave.methvin@gmail.com> | 2011-10-23 22:25:13 -0400 |
---|---|---|
committer | Dave Methvin <dave.methvin@gmail.com> | 2011-10-24 11:18:18 -0400 |
commit | 4ac6f8d9d322c7e468ed0d58e402abe7bdca354d (patch) | |
tree | 6c93204fd084fdb68b52a14bc9b876c8e6b1796c /test/unit | |
parent | b208042f520b2ee768a93323d6bdc65eabfb0d65 (diff) | |
download | jquery-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.js | 14 |
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); |