Skip to content
Permalink
Browse files

Using "hasOwnProperty" to check for direct properties "type" and

"namespace" on events before triggering.
  • Loading branch information
andrewplummer committed Jan 31, 2013
1 parent bb1d148 commit 5935a362c75ecef04d5ec9775cbcaf2165921e8d
Showing with 16 additions and 2 deletions.
  1. +2 −2 src/event.js
  2. +14 −0 test/unit/event.js
@@ -208,8 +208,8 @@ jQuery.event = {

var i, cur, tmp, bubbleType, ontype, handle, special,
eventPath = [ elem || document ],
type = event.type || event,
namespaces = event.namespace ? event.namespace.split(".") : [];
type = core_hasOwn.call(event, 'type') ? event.type : event,
namespaces = core_hasOwn.call(event, 'namespace') ? event.namespace.split(".") : [];

cur = tmp = elem = elem || document;

@@ -2666,3 +2666,17 @@ test( "Check order of focusin/focusout events", 2, function() {
input.off();
});

test("make sure defining 'namespace' on String.prototype does not cause trigger() to error", function() {
expect(1);
var errored = false;
String.prototype.namespace = function() {
return "test";
};
try {
jQuery("<p>").trigger('foo.bar');
} catch( e ) {
errored = true;
}
equal(errored, false, 'trigger() should not have errored');
delete String.prototype.namespace;
});

0 comments on commit 5935a36

Please sign in to comment.
You can’t perform that action at this time.