Skip to main content

Bug Tracker

Side navigation

#12655 closed bug (worksforme)

Opened October 04, 2012 07:54PM UTC

Closed October 04, 2012 08:27PM UTC

Speed up event binding in event.js

Reported by: lihanli Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: git
Keywords: Cc:
Blocked by: Blocking:
Description

The event binding code is using two if statements to check if an event is a key event or a mouse event.

if ( rkeyEvent.test( name ) ) {
  jQuery.event.fixHooks[ name ] = jQuery.event.keyHooks;
}

if ( rmouseEvent.test( name ) ) {
  jQuery.event.fixHooks[ name ] = jQuery.event.mouseHooks;
}

But based on the rkeyevent and rmouseevent regexs and the list of events it is impossible for an event to be both a mouse event and key event.

Therefore I rewrote it as an if/else if statement. I'm putting the mouseevent test first because it's more common. Pull request incoming.

Attachments (0)
Change History (1)

Changed October 04, 2012 08:27PM UTC by rwaldron comment:1

_comment0: Thanks! Since that only happens once, i think it's safe to leave it as is.1349382526675871
resolution: → worksforme
status: newclosed

Thanks! Since that only happens once per event binding, i think it's safe to leave it as is.