Ticket #3379 (closed enhancement: fixed)
Patch to include event bubbling for trigger()
|Reported by:||danwrong||Owned by:||flesler|
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:
- 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).
- 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.