Bug Tracker

Opened 11 years ago

Closed 11 years ago

#3379 closed enhancement (fixed)

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
Blocked by: Blocking:

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 (1)

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

Download all attachments as: .zip

Change History (3)

Changed 11 years ago by danwrong

Attachment: bubble.patch added

Version of patch where tests clean up after themselves

comment:1 Changed 11 years ago by flesler

Cc: danwrong added
Owner: changed from brandon to flesler
Status: newassigned

comment:2 Changed 11 years ago by flesler

Resolution: fixed
Status: assignedclosed

This is now implemented, differently though.

Note: See TracTickets for help on using tickets.