diff options
author | Dave Methvin <dave.methvin@gmail.com> | 2012-08-28 10:07:16 -0400 |
---|---|---|
committer | Dave Methvin <dave.methvin@gmail.com> | 2012-08-28 10:07:16 -0400 |
commit | afd717df9e189d3e374ce938f03e2712f31c29e3 (patch) | |
tree | 9f36ebee37cc7e1354e3af7da83529281f635d37 /test | |
parent | c078b83b3fea891e0c228a9f2d101481678b4c9d (diff) | |
download | jquery-afd717df9e189d3e374ce938f03e2712f31c29e3.tar.gz jquery-afd717df9e189d3e374ce938f03e2712f31c29e3.zip |
Fix #12383. All selectors should be delegateTarget-relative
Diffstat (limited to 'test')
-rw-r--r-- | test/unit/event.js | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/test/unit/event.js b/test/unit/event.js index 74cf1b9b7..5f609247a 100644 --- a/test/unit/event.js +++ b/test/unit/event.js @@ -2343,9 +2343,10 @@ test("jQuery.off using dispatched jQuery.Event", function() { }); test( "delegated event with delegateTarget-relative selector", function() { - expect(2); - var markup = jQuery("<ul><li><a id=\"a0\"></a><ul id=\"ul0\"><li><a id=\"a0_0\"></a></li><li><a id=\"a0_1\"></a></li></ul></li></ul>").appendTo("#qunit-fixture"); + expect(3); + var markup = jQuery("<ul><li><a id=\"a0\"></a><ul id=\"ul0\"><li class=test><a id=\"a0_0\"></a></li><li><a id=\"a0_1\"></a></li></ul></li></ul>").appendTo("#qunit-fixture"); + // Positional selector (#11315) markup .on( "click", ">li>a", function() { ok( this.id === "a0", "child li was clicked" ); @@ -2356,7 +2357,24 @@ test( "delegated event with delegateTarget-relative selector", function() { }) .end() .find("a").click().end() - .remove(); + .find("#ul0").off(); + + // Non-positional selector (#12383) + markup = markup.wrap("<div />").parent(); + markup + .find("#ul0") + .on( "click", "div li a", function() { + ok( false, "div is ABOVE the delegation point!" ); + }) + .on( "click", "ul a", function() { + ok( false, "ul is the delegation point!" ); + }) + .on( "click", "li.test a", function() { + ok( true, "li.test is below the delegation point." ); + }) + .find("#a0_0").click(); + + markup.remove(); }); test("stopPropagation() stops directly-bound events on delegated target", function() { |