Bug 89041

Summary: Click events from child element of disabled <button> incorrectly bubble
Product: WebKit Reporter: john van horn <jmvanhorn>
Component: UI EventsAssignee: Nobody <webkit-unassigned>
Status: UNCONFIRMED ---    
Severity: Normal CC: ap, me, pf
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Macintosh   
OS: OS X 10.6   
URL: http://jsfiddle.net/sjRtk/3/
Attachments:
Description Flags
html/js example of incorrect bubbling none

Description john van horn 2012-06-13 15:10:37 PDT
If a disabled <button> element contains a child element, then clicking on the child causes a click event to bubble up to the button's containing element.

Example:

<div id="btn-container">
    <button disabled>
        <i class="icon">XX</i>
        disabled-icon
    </button>
</div>

If an event listener is added to #btn-container for 'click' events, then clicking on the <i> element ("XX", contained in disabled button) causes the handler to be invoked. Clicking on the button's other content ("disabled-icon" text) does not invoke the handler.
Comment 1 john van horn 2012-06-13 15:11:19 PDT
Created attachment 147422 [details]
html/js example of incorrect bubbling
Comment 2 Pablo Flouret 2012-06-20 17:09:15 PDT
html spec says about disabled form controls and events:

"A form control that is disabled must prevent any click events that are queued on the user interaction task source from being dispatched on the element."

http://www.whatwg.org/specs/web-apps/current-work/multipage/association-of-controls-and-forms.html#attr-fe-disabled

The problem seems to be that the event's target is set to the button's child element, other browsers have the button as target.
Not sure what code is really to blame, hit testing?

As an aside, all browsers seem to be doing something different with regards to mouse events and disabled form controls, maybe that's why the spec only talks about the click events, where all browsers sort of agree.

I used something like this to play around, http://jsfiddle.net/EqfZ9/1/
Comment 3 Alexey Proskuryakov 2012-10-19 13:14:38 PDT
See also: bug 15696, bug 99712.