Skip to content

Commit

Permalink
You can get the .bind event namespace via event.handleObj.namespace, …
Browse files Browse the repository at this point in the history
…but what about the .trigger namespace? I propose event.namespace.
  • Loading branch information
cowboy committed Feb 28, 2010
1 parent 5353c6b commit e99646d
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/event.js
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ jQuery.event = {
},

handle: function( event ) {
var all, handlers, namespaces, namespace, events;
var all, handlers, namespaces, namespace_sort, namespace_re, events;

event = arguments[0] = jQuery.event.fix( event || window.event );
event.currentTarget = this;
Expand All @@ -379,7 +379,8 @@ jQuery.event = {
if ( !all ) {
namespaces = event.type.split(".");
event.type = namespaces.shift();
namespace = new RegExp("(^|\\.)" + namespaces.slice(0).sort().join("\\.(?:.*\\.)?") + "(\\.|$)");
namespace_sort = namespaces.slice(0).sort();
namespace_re = new RegExp("(^|\\.)" + namespace_sort.join("\\.(?:.*\\.)?") + "(\\.|$)");
}

events = jQuery.data(this, "events");
Expand All @@ -393,12 +394,13 @@ jQuery.event = {
var handleObj = handlers[ j ];

// Filter the functions by class
if ( all || namespace.test( handleObj.namespace ) ) {
if ( all || namespace_re.test( handleObj.namespace ) ) {
// Pass in a reference to the handler function itself
// So that we can later remove it
event.handler = handleObj.handler;
event.data = handleObj.data;
event.handleObj = handleObj;
event.namespace = all ? '' : namespace_sort.join(".");

var ret = handleObj.handler.apply( this, arguments );

Expand Down

1 comment on commit e99646d

@cowboy
Copy link
Owner Author

@cowboy cowboy commented on e99646d Mar 2, 2010

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.