Side navigation
#7793 closed bug (fixed)
Opened December 16, 2010 03:43PM UTC
Closed December 27, 2010 07:30PM UTC
Last modified March 14, 2012 02:48AM UTC
$.fn.delegate does not reflect event.preventdefault() from earlier $.fn.bind
Reported by: | rjgotten | Owned by: | dmethvin |
---|---|---|---|
Priority: | low | Milestone: | 1.5 |
Component: | event | Version: | 1.4.4 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
When an event has its default behaviour prevented in a handler added with $.fn.bind(), a handler higher up the hierarchy added with $.fn.delegate() reports that the event does not have its default behaviour prevented.
Provided is a jsFiddle illustrating the issue:
1. The bound handler executes.
- The event's default behaviour is prevented.
- A reference to the event object is retained.
2. The delegated handler executes.
- The event's status is checked with isDefaultPrevented(). It returns false.
- The reference to the event object is compared with the retained reference from the bound handler. The event objects are not the same event.
Attachments (0)
Change History (5)
Changed December 23, 2010 06:54PM UTC by comment:1
component: | unfiled → event |
---|---|
milestone: | 1.next → 1.5 |
owner: | → dmethvin |
priority: | undecided → low |
status: | new → assigned |
Changed December 24, 2010 01:14AM UTC by comment:2
summary: | $.fn.delegate does not honor event.preventdefault() from earlier $.fn.bind → $.fn.delegate does not reflect event.preventdefault() from earlier $.fn.bind |
---|
Changed December 27, 2010 07:30PM UTC by comment:3
resolution: | → fixed |
---|---|
status: | assigned → closed |
When a native browser event is bubbling up the DOM, make sure that the correct isDefaultPrevented value is reflected by jQuery's Event object. Fixes #7793.
Changeset: 64ee5581afd6e9667ad45e75f082c95e2725efa6
Changed December 28, 2010 01:31AM UTC by comment:4
When a native browser event is bubbling up the DOM, make sure that the correct isDefaultPrevented value is reflected by jQuery's Event object. Fixes #7793.
Changeset: 64ee5581afd6e9667ad45e75f082c95e2725efa6
Changed January 17, 2011 08:46PM UTC by comment:5
Landed updated tests:
https://github.com/jquery/jquery/commit/987c44bee48557f693a59bc7ecc1bbe1718c428c
The event delivered by .bind() is on the actual element, but the one delivered by .delegate() is on the delegated parent element. They are not the same Event object as the test case shows. I think it should be possible to initialize the propagated event to reflect reality though, I'll try some tests.