Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
jquery.event: Patch for #2708
  • Loading branch information
jzaefferer committed Apr 22, 2008
1 parent 6d28ebf commit 32b1cb3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/event.js
Expand Up @@ -293,6 +293,9 @@ jQuery.event = {
originalEvent.cancelBubble = true;
};

// Fix timeStamp
event.timeStamp = event.timeStamp || +new Date;

// Fix target property, if necessary
if ( !event.target )
event.target = event.srcElement || document; // Fixes #1925 where srcElement might not be defined either
Expand Down
10 changes: 9 additions & 1 deletion test/unit/event.js
Expand Up @@ -165,7 +165,7 @@ test("unbind(event)", function() {
ok( !jQuery.data(el[0], "events"), "Removed the events expando after all handlers are unbound." );

reset();
var clickCounter = mouseoverCounter = 0;
var clickCounter = (mouseoverCounter = 0);
var handler = function(event) {
if (event.type == "click")
clickCounter += 1;
Expand Down Expand Up @@ -304,3 +304,11 @@ test("jQuery(function($) {})", function() {
start();
});
});

test("event properties", function() {
stop();
$("#simon1").click(function(event) {
ok( event.timeStamp, "assert event.timeStamp is present" );
start();
}).click();
});

0 comments on commit 32b1cb3

Please sign in to comment.