aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/event.js4
-rw-r--r--test/unit/event.js14
2 files changed, 17 insertions, 1 deletions
diff --git a/src/event.js b/src/event.js
index a880bb647..0a85bf43c 100644
--- a/src/event.js
+++ b/src/event.js
@@ -403,7 +403,9 @@ jQuery.event = {
matches = [];
for ( i = 0; i < delegateCount; i++ ) {
handleObj = handlers[ i ];
- sel = handleObj.selector;
+
+ // Don't conflict with Object.prototype properties (#13203)
+ sel = handleObj.selector + " ";
if ( matches[ sel ] === undefined ) {
matches[ sel ] = handleObj.needsContext ?
diff --git a/test/unit/event.js b/test/unit/event.js
index 041920a53..bc98f73cb 100644
--- a/test/unit/event.js
+++ b/test/unit/event.js
@@ -1797,6 +1797,20 @@ test( "delegated event with delegateTarget-relative selector", function() {
markup.remove();
});
+test( "delegated event with selector matching Object.prototype property (#13203)", function() {
+ expect(1);
+
+ var matched = 0;
+
+ jQuery("#foo").on( "click", "toString", function( e ) {
+ matched++;
+ });
+
+ jQuery("#anchor2").trigger("click");
+
+ equal( matched, 0, "Nothing matched 'toString'" );
+});
+
test("stopPropagation() stops directly-bound events on delegated target", function() {
expect(1);