Bug Tracker

Modify

Ticket #2522 (closed enhancement: fixed)

Opened 6 years ago

Last modified 6 years ago

Remove isFunction from jQuery.event.trigger

Reported by: spinal007 Owned by:
Priority: major Milestone: 1.2.4
Component: event Version: 1.2.3
Keywords: Cc:
Blocking: Blocked by:

Description

In jQuery.event.trigger: if ( jQuery.isFunction( jQuery.data(elem, "handle") ) )

val = jQuery.data(elem, "handle").apply( elem, data );

Problem 1: That's 2 calls to jQuery.data and one possibly useless call to jQuery.isFunction.

Problem 2: Is it really necessary to check if jQuery.data(elem, "handle") is a function ? what else could it be?

Proposed change: var handle = jQuery.data(elem, "handle"); if(handle) val = handle.apply( elem, data );

Change History

comment:1 Changed 6 years ago by flesler

This proposal was made by me here:  http://groups.google.com/group/jquery-dev/browse_thread/thread/8cce225d143bdbfa/ce3d4c1f616ee06c#ce3d4c1f616ee06c

It's not a genius invention, but you should mention that anyway, I think. Also linking to the original discussion thread is usually good for the devs.

comment:2 Changed 6 years ago by brandon

  • Status changed from new to closed
  • Resolution set to fixed

Applied in Rev [5276]

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.