Merge branch 'eventprops.1.6final' of https://github.com/rwldrn/jquery into rwldrn-eventprops.1.6final

Conflicts:
	test/unit/event.js
This commit is contained in:
jeresig 2011-04-10 16:28:15 -04:00
commit 2c74ee46ee
2 changed files with 36 additions and 4 deletions

View file

@ -1,6 +1,7 @@
(function( jQuery ) {
var rnamespaces = /\.(.*)$/,
var hasOwn = Object.prototype.hasOwnProperty,
rnamespaces = /\.(.*)$/,
rformElems = /^(?:textarea|input|select)$/i,
rperiod = /\./g,
rspace = / /g,
@ -563,7 +564,15 @@ jQuery.Event = function( src ) {
// Event object
if ( src && src.type ) {
this.originalEvent = src;
this.type = src.type;
// Push explicitly provided properties onto the event object
for ( var prop in src ) {
// Ensure we don't clobber jQuery.Event prototype
// with own properties.
if ( hasOwn.call( src, prop ) ) {
this[ prop ] = src[ prop ];
}
}
// Events bubbling up the document may have been marked as prevented
// by a handler lower down the tree; reflect the correct value.
@ -852,10 +861,10 @@ function trigger( type, elem, args ) {
// Create "bubbling" focus and blur events
if ( !jQuery.support.focusinBubbles ) {
jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
// Attach a single capturing handler while someone wants focusin/focusout
var attaches = 0;
jQuery.event.special[ fix ] = {
setup: function() {
if ( attaches++ === 0 ) {
@ -1168,3 +1177,4 @@ jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblcl
});
})( jQuery );

View file

@ -975,6 +975,27 @@ test("trigger(eventObject, [data], [fn])", function() {
$parent.unbind().remove();
});
test("jQuery.Event({ /* props */ })", function() {
expect(4);
var event = jQuery.Event({ type: "keydown", keyCode: 64 }),
handler = function( event ) {
ok( "keyCode" in event, "Special property 'keyCode' exists" );
equal( event.keyCode, 64, "event.keyCode has explicit value '64'" );
};
// Supports jQuery.Event implementation
equal( event.type, "keydown", "Verify type" );
ok( "keyCode" in event, "Special 'keyCode' property exists" );
jQuery("body").bind( "keydown", handler ).trigger( event );
jQuery("body").unbind( "keydown" );
});
test("jQuery.Event.currentTarget", function(){
expect(1);
@ -2151,3 +2172,4 @@ test("event properties", function() {
}).click();
});
*/