diff options
author | Dave Methvin <dave.methvin@gmail.com> | 2011-04-11 11:15:00 -0400 |
---|---|---|
committer | Dave Methvin <dave.methvin@gmail.com> | 2011-04-11 11:15:00 -0400 |
commit | 530c915553dd21f7f933d6d1ca8102ae714f5aa2 (patch) | |
tree | e1e7db03968da4d781383572553768f761ef5aad /src | |
parent | bb520104426136c5dd3a78ba5955158b397fa2f6 (diff) | |
download | jquery-530c915553dd21f7f933d6d1ca8102ae714f5aa2.tar.gz jquery-530c915553dd21f7f933d6d1ca8102ae714f5aa2.zip |
Move initialization of event until we determine if anyone wants it.
Diffstat (limited to 'src')
-rw-r--r-- | src/event.js | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/src/event.js b/src/event.js index 3d19e50c2..95f305bab 100644 --- a/src/event.js +++ b/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) |