Fix some spacing and comment issues that crept in with the rebase.

This commit is contained in:
Dave Methvin 2011-04-06 11:34:41 -04:00
parent 29386db319
commit 879be3d812

View file

@ -284,19 +284,19 @@ jQuery.event = {
namespaces = [], namespaces = [],
cur = elem; cur = elem;
event = typeof event === "object" ? event = typeof event === "object" ?
// jQuery.Event object // jQuery.Event object
event[ jQuery.expando ] ? event : event[ jQuery.expando ] ? event :
// Object literal // Object literal
jQuery.extend( jQuery.Event(type), event ) : jQuery.extend( jQuery.Event(type), event ) :
// Just the event type (string) // Just the event type (string)
jQuery.Event(type); jQuery.Event(type);
if ( type.indexOf("!") >= 0 ) { if ( type.indexOf("!") >= 0 ) {
// Exclusive events trigger only for the bare event type (no namespaces) // Exclusive events trigger only for the bare event type (no namespaces)
event.type = type = type.slice(0, -1); event.type = type = type.slice(0, -1);
event.exclusive = true; event.exclusive = true;
} }
if ( type.indexOf(".") >= 0 ) { if ( type.indexOf(".") >= 0 ) {
// Namespaced trigger; create a regexp to match event type in handle() // Namespaced trigger; create a regexp to match event type in handle()
namespaces = type.split("."); namespaces = type.split(".");
@ -306,50 +306,50 @@ jQuery.event = {
event.namespace = namespaces.join("."); event.namespace = namespaces.join(".");
event.namespace_re = new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.)?") + "(\\.|$)"); event.namespace_re = new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.)?") + "(\\.|$)");
// Handle a global trigger // Handle a global trigger
if ( !elem ) { if ( !elem ) {
// Don't bubble custom events when global (to avoid too much overhead) // Don't bubble custom events when global (to avoid too much overhead)
event.stopPropagation(); event.stopPropagation();
// Save some time, only trigger if we've ever bound an event for this type // Save some time, only trigger if we've ever bound an event for this type
if ( jQuery.event.global[ type ] ) { if ( jQuery.event.global[ type ] ) {
// XXX This code smells terrible. event.js should not be directly // XXX This code smells terrible. event.js should not be directly
// inspecting the data cache // inspecting the data cache
jQuery.each( jQuery.cache, function() { jQuery.each( jQuery.cache, function() {
// internalKey variable is just used to make it easier to find // internalKey variable is just used to make it easier to find
// and potentially change this stuff later; currently it just // and potentially change this stuff later; currently it just
// points to jQuery.expando // points to jQuery.expando
var internalKey = jQuery.expando, var internalKey = jQuery.expando,
internalCache = this[ internalKey ]; internalCache = this[ internalKey ];
if ( internalCache && internalCache.events && internalCache.events[ type ] ) { if ( internalCache && internalCache.events && internalCache.events[ type ] ) {
jQuery.event.trigger( event, data, internalCache.handle.elem ); jQuery.event.trigger( event, data, internalCache.handle.elem );
} }
}); });
}
return;
} }
return;
}
// Don't do events on text and comment nodes // Don't do events on text and comment nodes
if ( elem.nodeType === 3 || elem.nodeType === 8 ) { if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
return; return;
} }
// Clean up the event in case it is being reused // Clean up the event in case it is being reused
event.result = undefined; event.result = undefined;
event.target = elem; event.target = elem;
// Clone any incoming data and prepend the event, creating the handler arg list // Clone any incoming data and prepend the event, creating the handler arg list
data = jQuery.makeArray( data ); data = jQuery.makeArray( data );
data.unshift( event ); data.unshift( event );
// Fire event on the current element, then bubble up the DOM tree // Fire event on the current element, then bubble up the DOM tree
do { do {
var handle = jQuery._data( cur, "handle" ); var handle = jQuery._data( cur, "handle" );
event.currentTarget = cur; event.currentTarget = cur;
if ( handle ) { if ( handle ) {
handle.apply( cur, data ); handle.apply( cur, data );
} }
// Trigger an inline bound script; IE<9 dies on special-char event name // Trigger an inline bound script; IE<9 dies on special-char event name
try { try {
@ -397,44 +397,43 @@ jQuery.event = {
}, },
handle: function( event ) { handle: function( event ) {
// It's rare to arrive without handlers to call, so do all setup now.
// Snapshot the handlers list since a called handler may add/remove events.
event = jQuery.event.fix( event || window.event ); event = jQuery.event.fix( event || window.event );
// Snapshot the handlers list since a called handler may add/remove events.
var handlers = ((jQuery._data( this, "events" ) || {})[ event.type ] || []).slice(0), var handlers = ((jQuery._data( this, "events" ) || {})[ event.type ] || []).slice(0),
all_handlers = !event.exclusive && !event.namespace, run_all = !event.exclusive && !event.namespace,
args = jQuery.makeArray( arguments ); args = jQuery.makeArray( arguments );
// Use the fix-ed Event rather than the (read-only) native event // Use the fix-ed Event rather than the (read-only) native event
args[0] = event; args[0] = event;
event.currentTarget = this; event.currentTarget = this;
for ( var j = 0, l = handlers.length; j < l; j++ ) { for ( var j = 0, l = handlers.length; j < l; j++ ) {
var handleObj = handlers[ j ]; var handleObj = handlers[ j ];
// Triggered event must 1) be non-exclusive and have no namespace, or // Triggered event must 1) be non-exclusive and have no namespace, or
// 2) have namespace(s) a subset or equal to those in the bound event. // 2) have namespace(s) a subset or equal to those in the bound event.
if ( all_handlers || event.namespace_re.test( handleObj.namespace ) ) { if ( run_all || event.namespace_re.test( handleObj.namespace ) ) {
// Pass in a reference to the handler function itself // Pass in a reference to the handler function itself
// So that we can later remove it // So that we can later remove it
event.handler = handleObj.handler; event.handler = handleObj.handler;
event.data = handleObj.data; event.data = handleObj.data;
event.handleObj = handleObj; event.handleObj = handleObj;
var ret = handleObj.handler.apply( this, args ); var ret = handleObj.handler.apply( this, args );
if ( ret !== undefined ) { if ( ret !== undefined ) {
event.result = ret; event.result = ret;
if ( ret === false ) { if ( ret === false ) {
event.preventDefault(); event.preventDefault();
event.stopPropagation(); event.stopPropagation();
}
}
if ( event.isImmediatePropagationStopped() ) {
break;
} }
} }
if ( event.isImmediatePropagationStopped() ) {
break;
}
} }
}
return event.result; return event.result;
}, },