Bug Tracker

Modify

Ticket #7793 (closed bug: fixed)

Opened 3 years ago

Last modified 2 years ago

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

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.

Change History

comment:1 Changed 3 years ago by dmethvin

  • Owner set to dmethvin
  • Priority changed from undecided to low
  • Status changed from new to assigned
  • Component changed from unfiled to event
  • Milestone changed from 1.next to 1.5

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.

comment:2 Changed 3 years ago by dmethvin

  • Summary changed from $.fn.delegate does not honor event.preventdefault() from earlier $.fn.bind to $.fn.delegate does not reflect event.preventdefault() from earlier $.fn.bind

comment:3 Changed 3 years ago by Dave Methvin

  • Status changed from assigned to closed
  • Resolution set to fixed

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 3 years ago by Dave Methvin

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

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.