#7793 closed bug (fixed)
$.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:
- The bound handler executes.
- The event's default behaviour is prevented.
- A reference to the event object is retained.
- 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.
Change History (5)
comment:1 Changed 12 years ago by
Component: | unfiled → event |
---|---|
Milestone: | 1.next → 1.5 |
Owner: | set to dmethvin |
Priority: | undecided → low |
Status: | new → assigned |
comment:2 Changed 12 years ago by
Summary: | $.fn.delegate does not honor event.preventdefault() from earlier $.fn.bind → $.fn.delegate does not reflect event.preventdefault() from earlier $.fn.bind |
---|
comment:3 Changed 12 years ago by
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
comment:4 Changed 12 years ago by
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
comment:5 Changed 12 years ago by
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.