Permalink
Browse files

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

…property
  • Loading branch information...
gibson042 committed Jan 14, 2013
1 parent de48668 commit 31b95797155077e4e670c0bbb2c57815f89769a1
Showing with 17 additions and 1 deletion.
  1. +3 −1 src/event.js
  2. +14 −0 test/unit/event.js
View
@@ -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 ?
View
@@ -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);

0 comments on commit 31b9579

Please sign in to comment.