mirror of
https://github.com/jquery/jquery.git
synced 2024-11-23 02:54:22 +00:00
Using "hasOwnProperty" to check for direct properties "type" and
"namespace" on events before triggering.
This commit is contained in:
parent
bb1d148345
commit
5935a362c7
@ -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;
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user