Open Bug 335020 Opened 18 years ago Updated 2 years ago

No nice way to watch for checkbox toggle (was: CheckboxStateChange does not fire from js-change for HTML)

Categories

(Core :: DOM: Events, defect, P5)

x86
Windows XP
defect

Tracking

()

People

(Reporter: dhtmlkitchen, Unassigned)

Details

(Keywords: testcase)

Attachments

(4 files)

Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.2) Gecko/20060308 Firefox/1.5.0.2

Problem: CheckboxStateChange is not properly implemented. 

CheckboxStateChange only fires from UI Event.
===================================================================================
http://www.xulplanet.com/references/elemref/ref_EventHandlers.html#attr_CheckboxStateChange
CheckboxStateChange

This event is sent when a checkbox is checked or unchecked, either by the user or a script. This event has no corresponding attribute; it must be added using the addEventListener method. Normally, you would use the command event to listen to checkbox changes, however, the command event is only sent when the user modifies the value, while the CheckboxStateChange event is also sent when a script modifies the checked property of a checkbox. For user changes, the CheckboxStateChange event is sent before the command event. The CheckboxStateChange event does not bubble.

===================================================================================

CheckboxStateChange should fire ANY TIME the checkbox's state is changed.

CheckboxStateChange should fire when the checkbox's state is changed from javascript. This is not happening in current release of FF.
Attached file XUL testcase
Well you are looking at an XUL reference so a XUL testcase would appear more appropriate and appears to work for me.

Is this event meant to be available in html? The DOM events spec has no mention of it.
Thanks for the XUL testcase, Dave. CheckboxStateChange is not part of DOM Events. 

DOMAttrModified is but DOMAttrModified does not fire for checkboxes when it's checked. Let me try to explain why I understand this to be so: 

Basically, the js property "checked" is not the attribute "checked". 

DOMAttrModified applies only when you modify and attribute. It does not apply when you modify the checked property, and the checked attribute is not changed! 

In fact clicking a checkbox and viewing the DOM source will NOT show checked="checked". Try it. You will see <input type="checkbox">. (because you didn't modify an attribute, but a property that updated the UI). Also, javascript:alert(cb.getAttribute("checked")) will still be null. Try it.

If CheckboxStateChange has partial/buggy implementation in HTML (but works great in XUL). It should either work or not work in HTML. 

The only viable alternative is to use checkboxEl.watch. 

CheckboxStateChange follows the DOM Events approach for subscribing to an event. It's Mozilla only. checkboxEl.watch requires a totally different approach. Another downside is that the event is lost.
There's really no clean way to go about it. 

This is about the best reason to implement CheckboxStateChanged. If it's not reason enough, then I don't know what is.
>If CheckboxStateChange has partial/buggy implementation in HTML (but works
>great in XUL). It should either work or not work in HTML. 

It does not work at all on trunk as far as I can tell.
Assignee: nobody → general
Component: General → DOM: HTML
Product: Firefox → Core
QA Contact: general → ian
Summary: CheckboxStateChange does not fire from js-change → No nice way to watch for checkbox toggle (was: CheckboxStateChange does not fire from js-change for HTML)
Version: unspecified → Trunk
Assignee: general → events
Component: DOM: HTML → DOM: Events
Partial support in:
 * Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.3) Gecko/20060426 Firefox/1.5.0.3

 * Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.1) Gecko/20060130 SeaMonkey/1.0

Nickolay, perhaps you did not try clicking the checkbox itself?
Or perhaps I checked the "trunk" build which is the latest development version of what will become Firefox 3.0.
1.5.0.4 ist the last Version for this test-case that fires DOMAttrModified. I'm showing here that even an explicit setAttribute on the checkbox does _nothing_ (try in 1.5.0.4, you can control the checkbox via the div/img).
Assignee: events → nobody
QA Contact: ian → events
https://bugzilla.mozilla.org/show_bug.cgi?id=1472046

Move all DOM bugs that haven't been updated in more than 3 years and has no one currently assigned to P5.

If you have questions, please contact :mdaly.
Priority: -- → P5
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: