Skip to content

Commit

Permalink
event: Stricter type checking in trigger - Fixes #13360 - Closes gh-1153
Browse files Browse the repository at this point in the history


Squashed commit of the following:

commit 5935a36
Author: Andrew Plummer <plummer.andrew@gmail.com>
Date:   Fri Feb 1 02:40:42 2013 +0900

    Using "hasOwnProperty" to check for direct properties "type" and
    "namespace" on events before triggering.
  • Loading branch information
andrewplummer authored and gnarf committed Jan 31, 2013
1 parent d79bf35 commit f005af5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/event.js
Expand Up @@ -207,8 +207,8 @@ jQuery.event = {
var handle, ontype, cur, var handle, ontype, cur,
bubbleType, special, tmp, i, bubbleType, special, tmp, i,
eventPath = [ elem || document ], eventPath = [ elem || document ],
type = event.type || event, type = core_hasOwn.call( event, "type" ) ? event.type : event,
namespaces = event.namespace ? event.namespace.split(".") : []; namespaces = core_hasOwn.call( event, "namespace" ) ? event.namespace.split(".") : [];


cur = tmp = elem = elem || document; cur = tmp = elem = elem || document;


Expand Down
14 changes: 14 additions & 0 deletions test/unit/event.js
Expand Up @@ -2674,3 +2674,17 @@ test( "Check order of focusin/focusout events", 2, function() {
input.off(); input.off();
}); });


test( "String.prototype.namespace does not cause trigger() to throw (#13360)", function() {
expect( 1 );
var errored = false;

String.prototype.namespace = function() {};

try {
jQuery("<p>").trigger("foo.bar");
} catch( e ) {
errored = true;
}
equal( errored, false, "trigger() did not throw exception" );
delete String.prototype.namespace;
});

0 comments on commit f005af5

Please sign in to comment.