Bug Tracker

Modify

Ticket #3379 (closed enhancement: fixed)

Opened 5 years ago

Last modified 4 years ago

Patch to include event bubbling for trigger()

Reported by: danwrong Owned by: flesler
Priority: minor Milestone: 1.3
Component: event Version: 1.2.6
Keywords: Cc: danwrong
Blocking: Blocked by:

Description

This is the first (and simplest) approach to adding bubbling to custom events. This patch adds a few lines to jQuery.event.trigger that programmatically bubbles events up through the document. It is syncronous at the moment but from what I can see it seems to work nicely and includes support for e.stopPropagation and e.preventDefault. It also seems to have little to no impact on the execution times of the tests which would suggest that there are no concerning slow downs although this could need more testing.

There are however two other approaches:

  1. Do similar to this but wrap in a setTimeout to make it asyncronous. As far as I can tell from running the tests it offers no benefit (aside from handlers being bubbled slightly slower).
  1. Attempt to create a bubble by piggybacking on a artificially created DOM element in a similar way to Prototype. This would require quiet a major rework of the trigger, add and remove methods and would be difficult to do without breaking existing features.

It would be great to get some feedback on this as there are lots of options to try to get this feature going and I'm willing to try different options if need be. I'm inclined to think that this option is the best at the moment though.

Attachments

bubble.patch Download (3.0 KB) - added by danwrong 5 years ago.
Version of patch where tests clean up after themselves

Change History

Changed 5 years ago by danwrong

Version of patch where tests clean up after themselves

comment:1 Changed 5 years ago by flesler

  • Cc danwrong added
  • Owner changed from brandon to flesler
  • Status changed from new to assigned

comment:2 Changed 4 years ago by flesler

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

This is now implemented, differently though.

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.