aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/event.js3
-rw-r--r--test/unit/event.js11
2 files changed, 13 insertions, 1 deletions
diff --git a/src/event.js b/src/event.js
index f0604503c..156bc016a 100644
--- a/src/event.js
+++ b/src/event.js
@@ -483,8 +483,9 @@ jQuery.event = {
for ( ; cur !== this; cur = cur.parentNode || this ) {
+ // Don't check non-elements (#13208)
// Don't process clicks on disabled elements (#6911, #8165, #11382, #11764)
- if ( cur.disabled !== true || event.type !== "click" ) {
+ if ( cur.nodeType === 1 && (cur.disabled !== true || event.type !== "click") ) {
matches = [];
for ( i = 0; i < delegateCount; i++ ) {
handleObj = handlers[ i ];
diff --git a/test/unit/event.js b/test/unit/event.js
index 2e86eb78d..c53690abb 100644
--- a/test/unit/event.js
+++ b/test/unit/event.js
@@ -1834,6 +1834,17 @@ test( "delegated event with selector matching Object.prototype property (#13203)
equal( matched, 0, "Nothing matched 'toString'" );
});
+test( "delegated event with intermediate DOM manipulation (#13208)", function() {
+ expect(1);
+
+ jQuery("#foo").on( "click", "[id=sap]", function() {});
+ jQuery("#sap").on( "click", "[id=anchor2]", function() {
+ document.createDocumentFragment().appendChild( this.parentNode );
+ ok( true, "Element removed" );
+ });
+ jQuery("#anchor2").trigger("click");
+});
+
test("stopPropagation() stops directly-bound events on delegated target", function() {
expect(1);