jquery.event: Patch for #2708

This commit is contained in:
Jörn Zaefferer 2008-04-22 21:59:40 +00:00
parent 6d28ebff85
commit 32b1cb3a5c
2 changed files with 12 additions and 1 deletions

View file

@ -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

View file

@ -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;
@ -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();
});