Skip to main content

Bug Tracker

Side navigation

#3379 closed enhancement (fixed)

Opened September 18, 2008 11:43PM UTC

Closed December 31, 2008 07:37PM UTC

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).

2. 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 September 19, 2008 09:45AM UTC.

    Version of patch where tests clean up after themselves

Change History (2)

Changed September 19, 2008 03:37PM UTC by flesler comment:1

cc: → danwrong
owner: brandonflesler
status: newassigned

Changed December 31, 2008 07:37PM UTC by flesler comment:2

resolution: → fixed
status: assignedclosed

This is now implemented, differently though.