@@ -331,11 +331,10 @@ jQuery.event = {
331331 // Make a writable jQuery.Event from the native event object
332332 event = jQuery . event . fix ( event ) ;
333333
334- var i , j , cur , ret , selMatch , matched , matches , handleObj , sel ,
334+ var i , j , ret , matched , handleObj ,
335335 handlerQueue = [ ] ,
336336 args = core_slice . call ( arguments ) ,
337337 handlers = ( jQuery . _data ( this , "events" ) || { } ) [ event . type ] || [ ] ,
338- delegateCount = handlers . delegateCount ,
339338 special = jQuery . event . special [ event . type ] || { } ;
340339
341340 // Use the fix-ed jQuery.Event rather than the (read-only) native event
@@ -347,41 +346,8 @@ jQuery.event = {
347346 return ;
348347 }
349348
350- // Determine handlers that should run if there are delegated events
351- // Avoid non-left-click bubbling in Firefox (#3861)
352- if ( delegateCount && ! ( event . button && event . type === "click" ) ) {
353-
354- for ( cur = event . target ; cur != this ; cur = cur . parentNode || this ) {
355-
356- // Ignore clicks (ONLY) on disabled elements (#6911, #8165, #11382, #11764)
357- if ( cur . disabled !== true || event . type !== "click" ) {
358- selMatch = { } ;
359- matches = [ ] ;
360- i = 0 ;
361- for ( ; i < delegateCount ; i ++ ) {
362- handleObj = handlers [ i ] ;
363- sel = handleObj . selector ;
364-
365- if ( selMatch [ sel ] === undefined ) {
366- selMatch [ sel ] = handleObj . needsContext ?
367- jQuery ( sel , this ) . index ( cur ) >= 0 :
368- jQuery . find ( sel , this , null , [ cur ] ) . length ;
369- }
370- if ( selMatch [ sel ] ) {
371- matches . push ( handleObj ) ;
372- }
373- }
374- if ( matches . length ) {
375- handlerQueue . push ( { elem : cur , handlers : matches } ) ;
376- }
377- }
378- }
379- }
380-
381- // Add the remaining (directly-bound) handlers
382- if ( handlers . length > delegateCount ) {
383- handlerQueue . push ( { elem : this , handlers : handlers . slice ( delegateCount ) } ) ;
384- }
349+ // Determine handlers
350+ handlerQueue = jQuery . event . handlers . call ( this , event , handlers ) ;
385351
386352 // Run delegates first; they may want to stop propagation beneath us
387353 i = 0 ;
@@ -419,6 +385,50 @@ jQuery.event = {
419385 return event . result ;
420386 } ,
421387
388+ handlers : function ( event , handlers ) {
389+ var i , matches , sel , handleObj ,
390+ handlerQueue = [ ] ,
391+ delegateCount = handlers . delegateCount ,
392+ cur = event . target ;
393+
394+ // Find delegate handlers
395+ // Black-hole SVG <use> instance trees (#13180)
396+ // Avoid non-left-click bubbling in Firefox (#3861)
397+ if ( delegateCount && cur . nodeType && ( ! event . button || event . type !== "click" ) ) {
398+
399+ for ( ; cur != this ; cur = cur . parentNode || this ) {
400+
401+ // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764)
402+ if ( cur . disabled !== true || event . type !== "click" ) {
403+ matches = [ ] ;
404+ for ( i = 0 ; i < delegateCount ; i ++ ) {
405+ handleObj = handlers [ i ] ;
406+ sel = handleObj . selector ;
407+
408+ if ( matches [ sel ] === undefined ) {
409+ matches [ sel ] = handleObj . needsContext ?
410+ jQuery ( sel , this ) . index ( cur ) >= 0 :
411+ jQuery . find ( sel , this , null , [ cur ] ) . length ;
412+ }
413+ if ( matches [ sel ] ) {
414+ matches . push ( handleObj ) ;
415+ }
416+ }
417+ if ( matches . length ) {
418+ handlerQueue . push ( { elem : cur , handlers : matches } ) ;
419+ }
420+ }
421+ }
422+ }
423+
424+ // Add the remaining (directly-bound) handlers
425+ if ( delegateCount < handlers . length ) {
426+ handlerQueue . push ( { elem : this , handlers : handlers . slice ( delegateCount ) } ) ;
427+ }
428+
429+ return handlerQueue ;
430+ } ,
431+
422432 // Includes some event props shared by KeyEvent and MouseEvent
423433 props : "altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which" . split ( " " ) ,
424434
0 commit comments