Bug Tracker

Modify

Ticket #8165 (closed bug: fixed)

Opened 3 years ago

Last modified 2 years ago

.live('click', handler) fires on disabled buttons with child elements in Chrome

Reported by: ms7821 Owned by: dmethvin
Priority: high Milestone: 1.7.2
Component: event Version: 1.5
Keywords: Cc: danheberden
Blocking: Blocked by:

Description

It's possible to receive events for a disabled <button> element as well as <input type="button">:

 http://jsfiddle.net/Fz2F3/ (jQuery 1.4.4)  http://jsfiddle.net/Fz2F3/1/ (jQuery 1.5)

IE fires click for all of them, passing the button as the target and currentTarget. This was fixed in jQuery 1.5 in http://bugs.jquery.com/ticket/6911.

Chrome fires only for the <button> with a child element, passing that as the target. However, currentTarget is set to the button, so changing target.disabled to currentTarget.disabled should extend the fix to include Chrome.

See also the first comment on  http://forum.jquery.com/topic/live-inconsistency-with-disabled-buttons.

Change History

comment:1 Changed 3 years ago by danheberden

  • Status changed from new to closed
  • Resolution set to duplicate

comment:2 Changed 3 years ago by danheberden

Duplicate of #6911.

comment:3 Changed 3 years ago by danheberden

  • Cc danheberden added
  • Component changed from unfiled to event
  • Milestone changed from 1.next to 1.5.1

comment:4 Changed 3 years ago by jitter

  • Priority changed from undecided to high

comment:5 Changed 2 years ago by dmethvin

  • Status changed from closed to reopened
  • Resolution duplicate deleted
  • Milestone 1.5.1 deleted

This bug still exists in 1.7.1, per the test case. It does look like changing to currentTarget will solve the problem.

comment:6 Changed 2 years ago by dmethvin

  • Owner set to dmethvin
  • Status changed from reopened to assigned
  • Milestone set to 1.7.2

comment:7 Changed 2 years ago by ms7821

Looks like it regressed in 1.7

Version 0, edited 2 years ago by ms7821 (next)

comment:8 Changed 2 years ago by Dave Methvin

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

Fix #8165: Ignore events bubbling through disabled elements.

Although #6911 fixed the case where event.target was disabled, it missed the case where the target was a sub-element.

Changeset: 8d9025ca50603e5404c6b50f7fa6c87046ee24c1

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.