diff options
author | Dave Methvin <dave.methvin@gmail.com> | 2012-01-28 14:58:00 -0500 |
---|---|---|
committer | Dave Methvin <dave.methvin@gmail.com> | 2012-01-28 16:30:35 -0500 |
commit | 633ca9c1610c49dbb780e565f4f1202e1fe20fae (patch) | |
tree | 379b62b9c5677e67fa57714bb4eb56b4464be761 /test/unit/event.js | |
parent | 499658970b2c9add7a7d175dffc8e263c3b7b50d (diff) | |
download | jquery-633ca9c1610c49dbb780e565f4f1202e1fe20fae.tar.gz jquery-633ca9c1610c49dbb780e565f4f1202e1fe20fae.zip |
Fix #11076. If .clone() won't delegate, we must remediate.
Since `jQuery.event.add` can accept a handleObj there's no need to reiterate them as args, but we *do* need to set the `selector` variable correctly.
Diffstat (limited to 'test/unit/event.js')
-rw-r--r-- | test/unit/event.js | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/test/unit/event.js b/test/unit/event.js index 4c1901664..dd4bbd55d 100644 --- a/test/unit/event.js +++ b/test/unit/event.js @@ -2657,6 +2657,29 @@ test(".on( event-map, null-selector, data ) #11130", function() { $p.on( map, null, data ).trigger("foo"); }); +test("clone() delegated events (#11076)", function() { + expect(3); + + var counter = { center: 0, fold: 0, centerfold: 0 }, + clicked = function( event ) { + counter[ jQuery(this).text().replace(/\s+/, "") ]++; + }, + table = + jQuery( "<table><tr><td>center</td><td>fold</td></tr></table>" ) + .on( "click", "tr", clicked ) + .on( "click", "td:first-child", clicked ) + .on( "click", "td:last-child", clicked ), + clone = table.clone( true ); + + clone.find("td").click(); + equal( counter.center, 1, "first child" ); + equal( counter.fold, 1, "last child" ); + equal( counter.centerfold, 2, "all children" ); + + table.remove(); + clone.remove(); +}); + test("delegated events quickIs", function() { expect(14); var markup = jQuery( |