Skip to content
Permalink
Browse files

Move initialization of event until we determine if anyone wants it.

  • Loading branch information...
dmethvin committed Apr 11, 2011
1 parent bb52010 commit 530c915553dd21f7f933d6d1ca8102ae714f5aa2
Showing with 18 additions and 15 deletions.
  1. +18 −15 src/event.js
@@ -289,35 +289,38 @@ jQuery.event = {
trigger: function( event, data, elem ) {
// Event object or event type
var type = event.type || event,
namespaces = [];

event = typeof event === "object" ?
// jQuery.Event object
event[ jQuery.expando ] ? event :
// Object literal
jQuery.extend( jQuery.Event(type), event ) :
// Just the event type (string)
jQuery.Event(type);
namespaces = [],
exclusive;

if ( type.indexOf("!") >= 0 ) {
// Exclusive events trigger only for the bare event type (no namespaces)
event.type = type = type.slice(0, -1);
event.exclusive = true;
// Exclusive events trigger only for the exact event (no namespaces)
type = type.slice(0, -1);
exclusive = true;
}
if ( type.indexOf(".") >= 0 ) {
// Namespaced trigger; create a regexp to match event type in handle()
namespaces = type.split(".");
event.type = type = namespaces.shift();
type = namespaces.shift();
namespaces.sort();
}
event.namespace = namespaces.join(".");
event.namespace_re = new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.)?") + "(\\.|$)");

if ( jQuery.event.customEvent[ type ] && !jQuery.event.global[ type ] ) {
// No jQuery handlers for this event type, and it can't have inline handlers
return;
}

// Caller can pass in an Event, Object, or just an event type string
event = typeof event === "object" ?
// jQuery.Event object
event[ jQuery.expando ] ? event :
// Object literal
jQuery.extend( jQuery.Event(type), event ) :
// Just the event type (string)
jQuery.Event(type);
event.namespace = namespaces.join(".");
event.namespace_re = new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.)?") + "(\\.|$)");
event.exclusive = exclusive;

// Handle a global trigger
if ( !elem ) {
// Don't bubble custom events when global (to avoid too much overhead)

0 comments on commit 530c915

Please sign in to comment.
You can’t perform that action at this time.