Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix #11315. Selector for .on() is relative to delegateTarget.
This fixes a regresssion from 1.6.4. Be aware that nearly every place that this bug comes into play, the selector in use is incredibly inefficient.
  • Loading branch information
dmethvin committed Jun 27, 2012
1 parent ad22218 commit 94e744a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/event.js
Expand Up @@ -384,7 +384,7 @@ jQuery.event = {

// Pregenerate a single jQuery object for reuse with .is()
jqcur = jQuery(this);
jqcur.context = this.ownerDocument || this;
jqcur.context = this;

for ( cur = event.target; cur != this; cur = cur.parentNode || this ) {

Expand Down
14 changes: 14 additions & 0 deletions test/unit/event.js
Expand Up @@ -2333,6 +2333,20 @@ test("jQuery.off using dispatched jQuery.Event", function() {
.remove();
});

test( "delegated event with delegateTarget-relative selector (#)", function() {
expect(1);
var markup = jQuery( '<ul><li><ul id="u1"><li id="f1"></li></ul></li>' ).appendTo("body");

markup
.find("#u1")
.on( "click", "li:first", function() {
ok( this.id === "f1" , "first li under #u1 was clicked" );
})
.find("#f1").click().end()
.end()
.remove();
});

test("stopPropagation() stops directly-bound events on delegated target", function() {
expect(1);

Expand Down

0 comments on commit 94e744a

Please sign in to comment.