Commit 94e744ae authored by Dave Methvin's avatar Dave Methvin

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.
parent ad222185
...@@ -384,7 +384,7 @@ jQuery.event = { ...@@ -384,7 +384,7 @@ jQuery.event = {
// Pregenerate a single jQuery object for reuse with .is() // Pregenerate a single jQuery object for reuse with .is()
jqcur = jQuery(this); jqcur = jQuery(this);
jqcur.context = this.ownerDocument || this; jqcur.context = this;
for ( cur = event.target; cur != this; cur = cur.parentNode || this ) { for ( cur = event.target; cur != this; cur = cur.parentNode || this ) {
......
...@@ -2333,6 +2333,20 @@ test("jQuery.off using dispatched jQuery.Event", function() { ...@@ -2333,6 +2333,20 @@ test("jQuery.off using dispatched jQuery.Event", function() {
.remove(); .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() { test("stopPropagation() stops directly-bound events on delegated target", function() {
expect(1); expect(1);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment