Commit 63f40866 authored by Richard Gibson's avatar Richard Gibson

Fix #13203: delegated events with selector matching Object.prototype property

(cherry picked from commit 31b95797)
parent 0a3a424e
...@@ -415,7 +415,9 @@ jQuery.event = { ...@@ -415,7 +415,9 @@ jQuery.event = {
matches = []; matches = [];
for ( i = 0; i < delegateCount; i++ ) { for ( i = 0; i < delegateCount; i++ ) {
handleObj = handlers[ i ]; handleObj = handlers[ i ];
sel = handleObj.selector;
// Don't conflict with Object.prototype properties (#13203)
sel = handleObj.selector + " ";
if ( matches[ sel ] === undefined ) { if ( matches[ sel ] === undefined ) {
matches[ sel ] = handleObj.needsContext ? matches[ sel ] = handleObj.needsContext ?
......
...@@ -1797,6 +1797,20 @@ test( "delegated event with delegateTarget-relative selector", function() { ...@@ -1797,6 +1797,20 @@ test( "delegated event with delegateTarget-relative selector", function() {
markup.remove(); 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() { 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