]> source.dussan.org Git - jquery.git/commitdiff
jquery event: closes #4033. e.currentTarget wasn't being enforced for native events...
authorAriel Flesler <aflesler@gmail.com>
Tue, 17 Feb 2009 12:38:16 +0000 (12:38 +0000)
committerAriel Flesler <aflesler@gmail.com>
Tue, 17 Feb 2009 12:38:16 +0000 (12:38 +0000)
src/event.js
test/unit/event.js

index e707015c10717c8e82a2206e3ed8a6e7a0e4d0ad..a50fe89fc59be80a5826acbe4c672ff0d197b5c0 100644 (file)
@@ -240,7 +240,8 @@ jQuery.event = {
                var all, handlers;
 
                event = arguments[0] = jQuery.event.fix( event || window.event );
-
+               event.currentTarget = this;
+               
                // Namespaced event handlers
                var namespaces = event.type.split(".");
                event.type = namespaces.shift();
index 1da9b5906fab6429850851e7068941ef51e1e483..840c98a5c3e39bff55a9ceddf6526d32661d1bba 100644 (file)
@@ -417,6 +417,20 @@ test("trigger(eventObject, [data], [fn])", function() {
        $parent.unbind().remove();
 });
 
+test("jQuery.Event.currentTarget", function(){
+       expect(2);
+       
+       var counter = 0,
+               $elem = jQuery('<button>a</button>').click(function(e){
+               equals( e.currentTarget, this, "Check currentTarget on "+(counter++?"native":"fake") +" event" );
+       });
+       
+       // Fake event
+       $elem.trigger('click');
+       // Native event (#4033)
+       triggerEvent( $elem[0], 'click' );
+});
+
 test("toggle(Function, Function, ...)", function() {
        expect(11);