]> source.dussan.org Git - jquery.git/commitdiff
Using "hasOwnProperty" to check for direct properties "type" and 1153/head
authorAndrew Plummer <plummer.andrew@gmail.com>
Thu, 31 Jan 2013 17:40:42 +0000 (02:40 +0900)
committerAndrew Plummer <plummer.andrew@gmail.com>
Thu, 31 Jan 2013 17:40:42 +0000 (02:40 +0900)
"namespace" on events before triggering.

src/event.js
test/unit/event.js

index 5841aff7ca64baf028c16ade040689f0e6c4aa54..fb9727867cd6df7b337a255943b2b5ee65655f24 100644 (file)
@@ -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;
 
index bde9f7f4315295255e0d6a45660c9274f810c1cb..2bede51faf8985a1a6a0d09812307c2f2900aa04 100644 (file)
@@ -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;
+});